-
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
Special token for marking a function as a promise generator #127
Comments
Two |
I don't see the benefit of having it look completely different from the other tokens. One would be able to do |
I didn't know this feature, that modifier composition is awesome. You should add this to the document. |
Why not have a syntactic support for decorators? I know Python decorators are kinda stupid when one has first-class functions, but the syntax of wrapping a function into another function isn't pleasant (as you've noticed here). I'm just thinking that maybe what we're looking at here is a new kind of concept (a function decorator) and, specifically, a new kind of macro operator (‘function postfix operator’) that should be (re-)definable? Currying, (un)binding and promise generation could all fit nicely into a single API (esp if we have a choice of making it a compile-time macro-based API). |
I actually was thinking about this and is likely the way I'll be going. You'd be able to register a single-character token that you could postfix a function's parameter list with. Currying would be redefined to use this, and then adding the % for promises or whatever would be something that could take up all of three lines. |
This depends on #131 now. |
Totally agree with the converging solution. The army of sigils gets a bit cryptic, characters/words seem better and allow custom ones (in VimScript you can do e.g. "function! func(a, b) abort" where abort is one such special keyword. But I guess full words wouldn't lend themselves well to anonymous functions?) |
Well, I'm not against the idea of >1 char signifiers on functions, but I'm not sure what the best syntax for specifying it would be. Sure the single char sigils may be cryptic, but I don't know a better way to keep the terseness of the code. At least for the builtin function modifiers, I'd like to keep them single-char. What would be a good syntax to specify multi-char, without confusing the distinction between a single-line function, e.g.
from a function with a modifier? |
In my community repo, I made this:
Be a promise generator. |
In some cases, the existing syntax of
promise! #()* ...
seems a little unwieldy, especially in the case of something like:or
It could be better to have another token such as
%
or&
or something along those lines that would automatically mark the function as a generator and wrap it withpromise!
The previous examples would then look like the following:
Any thoughts?
The text was updated successfully, but these errors were encountered: