-
Notifications
You must be signed in to change notification settings - Fork 108
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
Add syntax for "the previous value" #1144
Comments
I say let's do it! |
Agreed, we've talked about it a few times already! |
If we're looking to take a leaf from the Common Lisp book, that family of REPLs tends to have a feature that lets you access the kth value back. Are we interested in that, or should we just stick to previous? Also, this proposal is for a special binder. What do we think about a special expression instead?
or
where |
I find it the special expression quite confusing. Plus ^ is potentially useful for exponentiation, so better not to take it up IMO |
I was wondering about this too. On the one hand, I could see it being especially useful in a repl setting where you've just evaluated something and you want to do something with the result but you don't want to have to come up with a name for it. But I agree with Adam that the cost isn't worth it. Any syntax of this flavor breaks usually-semantics-preserving transformations, like inserting a pure decl above the line containing |
Here's an implementation plan: we make a new construct at the grouping level, say |
With @dougalm.
A use-case is when binding a large expression to a name, e.g.
Perhaps it would be nicer to write
where
=^
is a new lexeme meaning "bind to the previous value in the block". There is also precedent in other languages, especially at a REPL, for a magic identifier that means "the previous value".Reactions? Discuss!
The text was updated successfully, but these errors were encountered: