4 ms·
> I too had an ephiphany when I realized Elixir was actually a Lisp. Is it actually? Last time I looked at Elixir (granted, that was a while ago), the syntax f
by capableweb 3y ago
> I too had an ephiphany when I realized Elixir was actually a Lisp.
Is it actually? Last time I looked at Elixir (granted, that was a while ago), the syntax for writing macros was different than the syntax for writing ordinary code, so it fails even at a simple thing like that, it doesn't seem to support homogeneous meta-programming at all.
But again, I feel like I might be wrong here and I'm happy to be proven wrong.
- sodapopcan 3y agoYa, it's not actually a lisp. I can't find the source but José has stated part of the idea was to give you lisp-like metaprogramming with a non-lisp syntax (sorry, José, if I have mis-quoted). Even the regular syntax is sort of lispish, though, if you remove the syntactic sugar. It's all macros and datastructres. defmodule Foo do def bar do "baz" end end is really: defmodule Foo, do: (def bar, do: "baz") ...which is lispish if you squint the right way.
- zambal 3y agoA bit pedantic I guess, but that still uses some syntactic sugar (optional brackets and keyword syntax). Removing all syntactic sugar would look like this: defmodule(Foo, [{:do, def(:bar, [{:do, "baz"}])}]) Even aliases (like Foo) are also a kind of syntactic sugar for a specific type of atom (Foo is actually the atom :"Elixir.Foo")
- sodapopcan 3y agoHa, ya I meant remove the `do` sugar.
- foldr 3y agoThat’s just syntax sugar. Even the original Lisp was supposed to have sugar on top of S-expressions, although that never really happened. https://en.m.wikipedia.org/wiki/M-expression https://en.m.wikipedia.org/wiki/M-expression
- jjtheblunt 3y agoI think Mathematica has had a slight variant since 1988 (i've been using it since then, but never M-expressions, but they look awfully similar).
- anamexis 3y agoIt's listed under the "Implementations" section of that wiki article.
- bmitc 3y agoWhat is the actual failure? The macros are written with and by processing the built-in data structures.
- pmarreck 3y agoYou can write macros (as well as functions, actually) that accept AST and emit transformed AST back. It has quote and unquote. Turns out that it doesn't need homoiconicity to accomplish Lisp-level macro capability, which means it has all the power of a Lisp but with actual syntax (which is, like it or not, more appealing to many people) in a language with deep pattern-matching and completely immutable data guarantees.