4 ms·
Show HN: 入(rù-lang) – Clojurized JavaScript
- S4M 11y agoI would feel uncomfortable to use the quotest to define something, like: fact 'defn arity func' I think it would cause problems to have a good syntax hihlighting in the text editor.
- klibertp 11y agoThis is not a definition; it's a string with the description of what is being tested. Analogous to this code: it("contains spec with an expectation", function() { expect(true).toBe(true); });
- S4M 11y agoAfter re-reading the post it looks more like the helper in the lisp functions declarations. (defn fact (n) "factorial calculation" ...)
- klibertp 11y agoNOTE: 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#L1 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! :-)
- berdario 11y agoSame idea, but a bit more mature: https://github.com/lantiga/ki https://github.com/lantiga/ki Edit: Actually, it's completely different... I was too fast to judge upon reading: a new language built with mori+sweetjs for easier javascript interop But it might still be of interest to people here
- devty 11y agonice execution of an interesting idea! i see removing the parens as an effort to rid the 'lispy' feel to the language, but how do you go about lexical scoping without parens like clojurscript or indentation like coffeescript? For example, fact 'init variables and return expr' { should let(a=1,b=2){a+b} => 3; } to what point will the let bindings be valid?
- lgas 11y agoPresumably until the closing curly brace.
- ff7c11 11y agoWhat do I use this for? - confused out of touch javascript dev