Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: What's new in ECMAScript6, or: Oh no! Don't steal syntax from Perl!

by wrog (Friar)
on Jun 01, 2015 at 15:20 UTC ( [id://1128581]=note: print w/replies, xml ) Need Help??


in reply to Re^2: What's new in ECMAScript6, or: Oh no! Don't steal syntax from Perl!
in thread What's new in ECMAScript6, or: Oh no! Don't steal syntax from Perl!

but different because the result is code (a lisp list to be precise which is anything) and not a string like in Perl. And I've never seen this construct outside of macros. (does it even work?)

It does, actually. Keep in mind lisp doesn't really distinguish between code and data (the interior of a lambda is a list like everything else (*)). You can use the backquote anywhere you can use a regular quote. And this does come up: sometimes the backquote is the easiest way to build a complex data structure.

(Conversely, you can use a regular quote in a macro if you have a template that's actually constant, i.e., if there are no holes, then it doesn't matter which you use -- except in that people will expect the backquote, be confused if they don't see it, and it generally doesn't cost extra -- macro-expansion happens at compile time anyway),

(*) unless you're trying to do hygenic macros, in which case you need extra structure, i.e., it's not enough to build a list to represent your code; there needs to be something extra that remembers the state of the lexical environment at the point where the list was built so that when the various lists later get getting shuffled around in the course of macro expansion any variables included within will always be the "right" ones

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1128581]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-29 13:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found