Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

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

by wrog (Friar)
on May 30, 2015 at 19:50 UTC ( [id://1128423]=note: print w/replies, xml ) Need Help??


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

Looks more like Haskell to me
(minus the backslash-lambda thingie they use)

and the backquote stuff is almost certainly from Lisp (...though so is a fair amount of Perl, to be fair...)

  • Comment on Re: What's new in ECMAScript6, or: Oh no! Don't steal syntax from Perl!

Replies are listed 'Best First'.
Re^2: What's new in ECMAScript6, or: Oh no! Don't steal syntax from Perl!
by LanX (Saint) on May 30, 2015 at 23:51 UTC
    Well "let" is certainly lisp and that's where Perl got the concept of lexical variables from.

    The backquote in lisp is used in macro expansions if you want only some parts of the code to be expanded.(preceded by comma not dollar)

    That's similar to.variable.interpolation 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?)

    So yes this part is Perlish, but not particular, its also Bashish or even Shish (= omni shellish)

    I'd say back tick was taken to avoid backward incompatibilities with.double quotes as delimiter.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      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://1128423]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-23 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found