-
Notifications
You must be signed in to change notification settings - Fork 47
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
Modernize sibilant output #98
Comments
I've written sibilant macros which compile to these forms, it is relatively easy. (macro => (args ...body)
["((" ...(interleave ", " args.contents) ") => {\n\t"
(indent (apply ^do body))
"\n})"]) this implements an arrow function (macro class (name super-class body)
"create an es6 style class."
["class " name
...(if body (interleave " " [" extends" super-class ]) [])
" "
`(curly ...@(.map (get (or body super-class)
"contents") global.lit-macros ))]) this implements the class syntax, which I based this on top of some macros I built implementing the various new object literal syntaxes (meta
(macro lit (...body) `(literal ...@(.map body global.lit-macros )))
(macro describe (name ...body)
`(mixin (lit ...@body) @name))
(macro transpile-and-format (form)
`(pipe @form
transpile
output-formatter))
(macro def-lit-macro (name args ...body)
(assign name (transpile-name `(@ name)))
(var t (transpile-and-format `(lambda @args ...@body)))
(set lit-macros name (eval t))
null)
(def global.lit-macros (el)
(if (expression? el)
(do (var name (transpile-name el))
(if (and (literal? (first el.contents))
(has-key? lit-macros name))
((get lit-macros name) (dots (rest (content-of el))))
`(property ...@(content-of el)))) el))
(def lit-macros.init (args ...body)
`(init @args ...@body))
(def lit-macros.gett (name ...body)
`(gett @name ...@body))
(def lit-macros.alias (name from)
`(alias @name @from))
(def lit-macros.sett (name value-name ...body)
`(sett @name @value-name ...@body))) |
But I never use the class syntax, I'm not a fan of it much. I mostly wrote it to understand the macroing system of sibilant a bit better. If your interested, I've got a whole tool set of macros and other tools for working with sibilant and the newer versions of js. |
Hey @riatzukiza, I really think these macros (or some of them) should be in sibilant proper. I don't particularly love classes either, but some APIs require them, so using sibilant at least allows you to author them in a functional way. |
This is part of jbr#98 and adds the "const" macro. It's just like "var" but produces JavaScript constants: ```lisp (const a 3) ```
@riatzukiza I'd love to see those macros, either PRed into sibilant core or possibly as a package of macros that would be easy to npm install and include. One of my goals for this project was to make it easy to publish macros on npm, which potentially could be as large as whole language variants. I imagine some work would be required to actually achieve that goal, but I'd love to see it happen. If the changes are very sweeping or don't belong in core, it would be awesome to have an official list of dialects or macro sets listed prominently on the readme and docs |
https://github.com/riatzukiza/kit This is the core language I use in several other libraries, which I am getting ready to publish to npm all together. |
I recently published several of the other libraries I've written with sibilant as well: Kits (libs)https://github.com/riatzukiza/kit-interface This last one is broken atm, theres definately a working version some where in the git history, and I have a plan of action for this lib, it just keeps getting pushed back every time I touch it. https://github.com/riatzukiza/kit-http ProgramsHere are a few programs I wrote with sibilant as well. No garentee that these run/compile with out some work atm though. Its on my list of things to get fixed. the "kits" are a lot more stable than the programs. There will be other programs published in the near future, I've written a lot. I have a lot of time on my hands. |
I think there would be some benefit of modernizing sibilant js output to modern ES201x. In particular it would be good to support:
This would of course be a breaking change
The text was updated successfully, but these errors were encountered: