What's Js equivalent to this?
(defmacro catch-error [& code]
`(try ~@code (catch Exception e#)))
-
-
Replying to @yogthos @ShriramKMurthi and
That ` looks a lot like a quoted string and that ~ looks a lot like string interpolation, so if that eval ran at compile-time on constexpr string data and caught errors statically...
2 replies 0 retweets 1 like -
Replying to @TimSweeneyEpic @yogthos and
The big idea is "defmacro" itself; same form as a function definition, but extending the compiler instead of the program. You then get the full language power at compile-time; ` and ~@ are just sugar for list manipulations. You can hack the language itself in your application.
2 replies 0 retweets 2 likes -
Replying to @Lambda_Coder @yogthos and
Yes! Point is: There’s an ismorphism (though a super crappy one) between JavaScript string concatenation and eval, and LISP quasiquote/unquote. After all, they’re both one-way: once data is evaled into code, it can’t go back.
2 replies 0 retweets 1 like -
Replying to @TimSweeneyEpic @Lambda_Coder and
Sure, but that's a separate point from the fact that in Lisp I'm transforming structured data, while I'm cobbling strings together in Js. Imagine implementing something like this https://github.com/clojure/core.logic … using Js approach. There's a qualitative difference here.
1 reply 0 retweets 0 likes -
Replying to @yogthos @Lambda_Coder and
Agreed. Given the isomorphism (ability to transform either representation losslessly to the other), the differences are performance and aesthetics. LISP beats JS but there’s probably a more optimal answer using traditional syntax.
1 reply 0 retweets 0 likes -
Replying to @TimSweeneyEpic @yogthos and
I don't know why we're arguing aesthetics. I never brought up or disputed aesthetics. I'm one of the people behind
@racketlang for goodness sake! And I built the original Racket s-exp and macro system. Being 'splained on these topics by paren newbies is pretty hilarious. »2 replies 0 retweets 1 like -
Replying to @ShriramKMurthi @TimSweeneyEpic and
I asked for a DEFINITION of h11y. I've gotten a bunch of non-definitions, definitions-that-don't-define-the-right-set, "then you tell me how"s, etc. And now we've shifted the goalposts completely to "how well would you do string concats". Funny! »
1 reply 0 retweets 0 likes -
Replying to @ShriramKMurthi @TimSweeneyEpic and
But even then,
@TimSweeneyEpic, I'd be careful about a term like isomorphism, at least if I understand what your context — and maybe I don't. Isomorphism between what and what, exactly?1 reply 0 retweets 0 likes -
Replying to @ShriramKMurthi @yogthos and
There is a one-to-one (mod whitespace etc) mapping between strings representing valid code and abstract syntax trees, so anything expressible in terms of quasiquote/unquote can be transformed losslessly to be expressed as concatenation and eval, and vice-versus.
2 replies 0 retweets 1 like
The string version is far clunkier than the Sexpr version for sure! But it’s no less expressive. This is not the case with, for example, C macros! They are strictly less expressive than a language with quote/unquote or eval because they can’t scrutinize tokens.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.