Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/calls in dot forms #2128

Merged
merged 2 commits into from
Jul 21, 2021

Conversation

allison-casey
Copy link
Contributor

closes #1108

This allows expressions in the attribute access macro . that compile to method calls, such that the following is now possible

=> (. os (getcwd) (isalpha) __class__ __name__ [0])
os.getcwd().isalpha().__class__.__name__[0]
'b'
=> (. "ab hello" (strip "ab ") (upper))
"ab hello".strip("ab ").upper()
"HELLO"

@Kodiologist
Copy link
Member

Looks good, but why the extra newline in test-attribute-access?

@allison-casey allison-casey force-pushed the feature/calls-in-dot-forms branch from 8ed4424 to f38f9aa Compare July 20, 2021 16:37
@allison-casey
Copy link
Contributor Author

fixed

@scauligi
Copy link
Member

Dope!
It looks like we're explicitly blocking unpack-* forms, but what about other specially-parsed forms like quote or annotate? (Should we do something about them explicitly?)

=> (. x ^y)
x.annotate(y)

=> (. x 'y)
x.quote(y)

@Kodiologist
Copy link
Member

While funny, that sort of behavior is probably not worth trying to prevent.

@allison-casey allison-casey merged commit 55a6a58 into hylang:master Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider extending Hy's . form to accept calls
3 participants