gorillascript icon indicating copy to clipboard operation
gorillascript copied to clipboard

Support for custom macro-based tokens on FunctionDeclaration

Open ckknight opened this issue 12 years ago • 0 comments

Currently the tokens applied to a FunctionDefinition (* for generator, @ for this-bound, ! for non-returning, ^ for curry) are all handled explicitly by the parser, when it could be better to promise a macro that would specify a "function postfix token" to provide the functionality. Changing ^ for currying to this system would be the easy first step.

These should be overrideable as current macros are.

The tokens should be pretty much any character, whether it be symbolic or alphanum and such, but not an existing special character like ( or another grouping, and should be a single character only (so you couldn't have a token called promise, but you could have one called p or $ or %).

As far as ordering goes, I'm thinking it will be applied to the function left-to-right, e.g.

#(x)%^& ->

Would apply %'s macro first, then ^, then & as if it were wrapped like so:

&(^(%(#(x) ->)))

Except that that syntax wouldn't be valid, as it would only work after a function's parameter list.

ckknight avatar Jul 16 '13 22:07 ckknight