Hacker News new | ask | show | jobs
by S4M 4024 days ago
After re-reading the post it looks more like the helper in the lisp functions declarations.

   (defn fact (n)
       "factorial calculation"
       ...)
1 comments

NOTE: It's the first time I see the code.

Actually, `fact`, `should`, etc. seem to be macros, as provided here:

https://github.com/jcouyang/ru/blob/master/macro/ruspec.sjs#...

And following lines. It is a bit of syntactic sweetness over a preexisting testing framework. And I'm not convinced that they should be macros.

Unless sweet.js does something really original, macros are generally not first-class. You can't pass macros directly as parameters to functions, for example. I'd rather use macros to allow for nicer function call and attribute access syntax, in general, instead of special casing tests.

After taking a closer look at the language, I have some doubts. As of right now the language seems to be a random set of features that the author found cool implemented as Sweet.js macros, with the rest of JavaScript syntax unchanged. It would be a library in a Lisp world, even in Racket I don't think this level of functionality would be enough to justify writing a #lang.

At least two of the implemented features shouldn't be macros: into and fact/should because they then become second-class objects. You can't, for example, use `into` as an argument to `map`. Shorter lambdas are fine, personally I feel that the `=>` syntax native to JS is enough for this - but that's a matter of preference.

All in all, it looks like a very early attempt and there's still much to implement and improve. Have fun with this, OP! :-)