-
Notifications
You must be signed in to change notification settings - Fork 156
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
Macros #328
Comments
More examples, but this time from something much closer to livescript: Gorillascript: |
While macros are awesome, their addition in a language that isn't homoiconic (and particularly one with a complex syntax like LiveScript) makes me a bit ambivalent towards them. Rust has them, and it has a C-style syntax, but I haven't had the time to analyse and play with Rust yet, so I can't comment on that. My experience with macros come from Scheme, Emacs Lisp & Clojure (second-class macros) and Io & Kernel (first-class "macros"). They do fit well in those languages because they're homoiconic, and have a rather simple syntax — yet debugging macros in Clojure is the most painful thing ever. I'm not sure LiveScript could just "add macros" without rethinking a lot of its syntax and features. If we can find a way to make them possible, I'm all for it, though. There are a few times where syntactical abstractions are an awesome thing to have. |
@killdream Gorillascript is not homoiconic and has convoluted syntax like livescript therefore proven prior-art exists. Regarding:
Rethining a lot of syntax and features would be a good thing #219. Tangent Linters #316 and styleguides https://github.com/gkz/LiveScript-style-guide should be considered possible language-design smells, simplicity can mean a compromise of fewer "options" in exchange for enhanced clarity. I'm skeptical of anyone who considers optional syntax a better feature than clarity. Maybe this goes into the /tangent Macros allow the community to engage in language design and help @gkz manage the language evolution by observing what popular userland macros are in use. |
So, I want to try something with bringing macros to LiveScript. I'm currently reading some papers on previous literature on this subject to see what would be the best way of bringing them. However, I'm not going for the overtly simplistic approach in (jashkenas/coffeescript#3171), but something that'll cover at least these points:
Though what I'm thinking right now would be a multi-pass compiler where macros would add a new pass and modify the transformation rules (a macro is a Transformer AST → Transformer AST function, basically). Not sure how well it would work, but could simplify the compiler architecture if turns out to be solid. The idea for now is mostly based on OMeta, and I don't think it could be just a drop-in feature. But maybe something to consider for LS2 if it turns out to be worthwile. Just throwing the idea here, but I still need to read some papers and draft most of it :P |
I have already proposed apply macros before and don't remember what you If yes it is compile time livescript which has access to input json. It allows me to generate livescript using livescrpt. And I am happy with But not I still not happy that livescript cannot use typescript interfaces
|
Example: $scope
..get-list= (name)->
/for list in radio-lists
if name is '{{list.name}}' then return {{JSON.stringify list.content}}
[]
where radio-lists is property of input json and {{ something }} is compile time livescript code |
Some other projects, for reference. |
glanced at it - cool! 2014/1/8 Joshua Kifer [email protected]
|
elixir macros offer a way for libraries to extend the language. For instance the range operator
..
in elixir is a macro – anyone in userland could have created it.The majority of elixir "syntax" is implemented using the same tools available to userland.
I think the benefits are obvious. For one thing, userland can try radical features and the things that stick can become integrated into core. DSLs become trivial...
I'm curious what you guys think. It's not obvious to me that
livescript 1.x
could adopt this and still be called, well,livescript
, but at the same time I also get the impression things are still up for grabs (or at least, say,LS2
might be).The text was updated successfully, but these errors were encountered: