-
Notifications
You must be signed in to change notification settings - Fork 34
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
Fix partial placeholder .
in middle of call chain
#1450
base: main
Are you sure you want to change the base?
Conversation
I have mixed feelings about this one... I think it could be handy to lift above trailing call expressions much lifting above. It's easy enough to short circuit the chain by adding parens:
But I don't know how we'd add in the chain easily if we switch it up. I could be convinced but I'd need to see some more examples. |
I can't think of many situations where I want to do multiple calls in a chain. Currying is the obvious example. The current behavior might be useful when currying: add := (x) => (y) => x+y
leftSpace := add(' ')(.) // works with or without PR
rightSpace := add(.)(' ') // relies on current behavior, not PR On the other hand, I think partial placeholders are designed to replace the need for currying in the first place: add := (x, y) => x+y
leftSpace := add(' ', .) // works with or without PR
rightSpace := add(., ' ') // works with or without PR Here are some arguments for why I think the PR behavior is better:
Admittedly, the examples are thin. If you can think of others to help decide, I'd love to see them! |
Thanks for the explanation, I'm mostly convinced, however there is one other situation I think needs to be considered:
Since there are very few properties of a function that are useful to access it is more generally useful to have the member expressions applied inside. By a similar argument we may even want to expand to the left further as well:
We could even extend to handle:
If we do |
Hmm, nice examples. I'm actually surprised that I guess this suggests an alternative interpretation for
The bold part is the new part compared to the current definition. Maybe we could stick to |
I think this is a good interpretation with the possible addition of statement and parenthesized expression as additional places that the lifting halts. I'm not very much of a fan of For multiple argument partial application I've been considering |
Ooh, parenthesized expression sounds like a nice place to stop lifting! Currently the lift just rips through that, which I think is counterintuitive and makes it hard to stop the lift (I usually use a (We already stop at statements, as previously discussed, but it should be documented!) I'm still uncertain whether
|
The delayed arguments seem to work ok already with this construct:
The way I think about (sorry for the close/reopen on this issue, fat fingered ctrl+enter when trying to paste code into the example) |
I just found myself writing the following code (here transpileds.map((&.about ?? '')# + &.code#) This wouldn't work if we stop |
Good point, maybe we should continue through parentheses. I can see it coming up in math equations pretty regularly. |
Fixes #1449