-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make a survey of languages with syntactic macros #489
Comments
The intent here being, of course, to explore the prior art in the field, both in order to be able to relate 007 to other things in some kind of ontology, and in order to |
I see sweetjs in the Wiki article (though perhaps you added it?). What are the points we’re most interested aboutin other impls? :) |
Looking forward to seeing this table! 👍 |
Just want to link this one in here: Dylan and the Lisp family tree's central core. The list of languages in that post seems worth following up on:
|
It seems I might have to include Wat in my list, too. |
Linking this syntax-rules primer from here, just to have it linked from somewhere. It also relates somewhat to #491. |
The first part is untrue, for us. The second part is at odds with some other features 007 wants. |
And also Virtua, by the Wat author (and "the Axis of Eval" blogger). Needless to say, some of these languages (especially the fexpr ones) are not mainstream, and I won't be able to write a lot about them. But there will still be something to say about "how does the language do macro-ish things?". |
@vendethiel, I forgot to reply properly. Doing so now.
No, but I think I might have missed it, or forgot it was there.
Any idea why?
For the table: approach to macro hygiene/gensyms, etc. Type of macros (procedural/pattern-matching). For the prose, some details about how the macro system "feels", what limits it sets up for itself wrt syntax and semantics, maybe what known weaknesses it has (such as Common Lisp and accidental capture), but balance it out with what things it provides (such as anaphoric macros). |
Probably a collection of factors: Disnet used to work at Mozilla, and they might've had time for open-source work (after all, sweetjs used to be under the mozilla github organisation). Maybe just lack of interest. |
Also perhaps include Z in the survey, although it seems a bit |
Also throwing this HN discussion in here. I feel I need to get somewhat of a handle on |
I think |
The use of a string reminds me of BlackCoffee somewhat. |
Also macropy. |
MetaOCaml. To the extent that I've looked at it, it has quasiquotation and unquotes, and these interact with the type system. |
Maybe D is worth mentioning in this context, because their official stance seems to be that they ended up not needing macros.
Granted, it's preprocessor/text macros they're talking about here, not real AST macros. But still. I think the most important part of that page is the last one, about template mixins. Haven't looked deeply, but it seems that they do merit the inclusion of D in this list. |
They do, a bit, using their compile-time reflection. |
Scala has def macros (still experiemental) and deserves at place in the survey. Rust also has macros, and the way to define them reminds me of |
The T reference manual (and by the way, I don't know yet if T deserves a slot of its own in this survey) contains this interesting tidbit: "T's quasiquote facility, inherited from the Maclisp family of Lisp...". Maclisp goes back a long, long way. It originated in the late 60s, and influenced Interlisp and later Common Lisp. But the claim that quasiquotes come from that language family is not backed up by the Maclisp reference manual, Revision Ø, from 1974. Maybe it was added later? Or there were variants/dialects of Maclisp, and quasiquotes weren't in the main one? |
Nor does this Interlisp reference manual (also from 1974) mention quasiquotes. |
Not sure if Scala def macros should « count » still, since they were deprecated for Scala 3/Dotty. |
Wow, a Big Rewrite. Where have I heard that before? 😄 Anyway, unless I've missed a big announcement, it's not a question of "they were deprecated", and more a question of "they wioll haven be deprecated". We'll cross that Subinverted Plagal Past Subjunctive when we get to it. |
As to how/where quasiquotes originated, The History of Lisp has much of the story. (See pp72-75.) Of note, they were originally called "pseudoquotes". (That is, the relation to Quine's quasiquotation is not there from the start.) One of the early practitioners of the art, including of nested quasiquotes, was Alan Bawden. Searching for "alan bawden mit nested quasiquote" gives this .ps.gz, which seems on skimming to be a very nice read. (PDF version.) On the way I also found this 1993 email where Jonathan Rees recounts Alan Bawden opining strongly that quasiquote expansion should be a part of the reader. (I don't know about other implementations, but it isn't in Bel; it's a macro. That is, you can write either ` This text mirthily quotes from Bawden's article, as well as provides a nice example of double-unquote, a
I use this macro especially because something tells me @vendethiel used it as an example years ago, and now he'll smack me over the head with it. Either for being a slow learner, or for having a memory like a colander, or both. |
A later reference work about MacLisp is apparently called "The Revised MACLISP Manual" but nicknamed The Pitmanual after its author, Kent M. Pitman (famous Lisp implementer/documenter, and co-star in acclaimed TV Series Breaking Bad). This one does mention backquoting and splicing. So all in all it would seem that quasiquoting and the backquote syntax was indeed invented during the evolution of the MacLisp family of LISPs. |
Ah yes, here: #30 (comment) — 3.5 years ago. |
I don't think I do either, if anything, I'm always surprised at how much you remember was mentioned around. :-) |
I guess I am my own harshest judge. 🙂 It's taken me this many years to wrap my head around all this stuff. To the extent I understand it even now, that is. |
Groovy has macros. Apparently, they grew out of their AST Transformers, and are documented together with them here. From what I can see, they don't address hygiene at all. (I might be wrong.) Groovy's |
@ALANVF Agreed, after checking the documentation of all those three. Hum, somehow I was aware of those languages, but forgot to consider them for this survey. Thanks! Also, dammit, Crystal's macros look like an impossible paradise version of Perl 6's macros. I should check them out some more. |
I think they've been mentioned quite a few times over the years on IRC. |
F# has code quotations, which look a lot like quasiquotes-done-right to me. Even the syntax somehow feels less horrible than par for the course. |
Huh. On page 18 of the "Resugaring" paper (recommended to me by @jnthn) there is actually a table not entirely unlike what I imagined for this issue. Probably would serve as a very good starting point. |
Agda has "reflection" (a way to turn code into AST objects inside the program itself), as well as quoting/unquoting and macros, as can be seen in this paper. I'm surprised and intrigued, even as I don't see the whole picture. There's something called "the elaborator", and a |
I think Idris has a similar mechanism as well |
I just found Axel, a Haskell with Lisp syntax and macros, quoting, and quasiquoting+unquotes. |
Whose name is Manuel J. Simoni, and... I just found yet another interesting implementation of his, called "ell" (short for "Executable and Linkable Lisp", it seems). It's interesting even as a toy because, judging by this LtU comment and its child, it implements "Dybvig's expansion-passing style". Judging from this commit, that seems to be based on the paper "Writing Hygienic Macros in Scheme with Syntax-Case" — one of those many papers I'm vaguely aware of but haven't actually read yet. |
Katahdin, of which I'm mighty surprised I hadn't heard before. There's a web page, a thesis, and an unpublished paper. It runs on PEG, which is interesting in itself. I have a language design brewing in a private repository which is not entirely unlike this one. (Although the differences are salient, too.) My language is code-named "Pear" (because I suck at naming and I used an online project name generator to pick an essentially random name), and uses Dylan's pattern macros as a jump-off point, but then mixes together one-pass parsing (à la Raku), custom operators with operator precedence (à la Raku and Alma, but better; I didn't think I had more to say about this but I did — short story — the operator precedence can form a partial order as long as that fact is never observed), and Krishnamurthi's idea of micros (no doubt my own interpretation of them; this gives us "hygienic labels" inside code quotes, and the ability to define Anyway. I will read the Katahdin thesis with interest, comparing it to what I already have in Pear. Maybe we're pushing the boundaries here on what's considered "languages with syntactic macros". That's fine, I think. It's the magic that counts. |
Passerine, which has a respectable pattern macro system that reminds me of Dylan's, but with metasyntax that looks more like Scheme's. Claims to be hygienic. |
Nemerle. Here's a paper: Meta-programming in Nemerle. (Edit: Here's another Syntax-extending and type-reflecting macros in an object-oriented language. Also, Nemerle is mentioned as an inspiration in an early paper on Scala macros.) |
Starting from the languages listed in https://en.wikipedia.org/wiki/Macro_(computer_science)#Syntactic_macros, make a table with the languages on the rows and capabilities on the columns.
After the table, also summarize each language in prose, pointing out tradeoffs and limitations; details that the table is too coarse to contain. Include plenty of links to resources on the web such as reference documentation and papers.
(Do not assume Wikipedia's list of languages is complete; if there are other languages that seem to fit the description of having syntactic macros, include them. For example, I'm pretty sure we also want to have SweetJS in there.)
The text was updated successfully, but these errors were encountered: