0

I've used Scheme and Clojure, I've played a lot with their macro systems and the lisp syntax(lack of syntax) possiblities.

However I haven't found many other languages with macro systems as sophisticated and useful as those in languages with Lisp syntax.(I don't count C/C++)

Are there some notable examples?

Alexander Ivanov
  • 524
  • 5
  • 18
  • I'm very interested in the answer to this question, but I do think that it's off topic for Stack Overflow: there's no single right answer here (though some answers could be factually wrong): "There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs." – Joshua Taylor Oct 18 '13 at 19:22
  • Take a look at Katahdin ( http://bit.ly/c5MEl ), Template Haskell, Nemerle, Converge, MetaOCaml, JetBrains MPS. – SK-logic Oct 18 '13 at 20:10
  • I ask for a good list of non-lisp languages with sophisticated macro systems, it seems like something that can be answered in a few paragraphs to me – Alexander Ivanov Oct 18 '13 at 21:40

3 Answers3

2

Dylan also has a macro system, and doesn't have the classic Lisp-like, fully-parenthesized syntax.

Allegedly Mathematica. I haven't used it myself, though as per this answer, it's quite a bit more confusing than Lisp/Scheme macros.

Depending on how you define "macro system", Template Haskell might count too.

Community
  • 1
  • 1
Inaimathi
  • 13,853
  • 9
  • 49
  • 93
1

Of Algol dialects with macros (meta programming capabilities) I can think of Nemerle and Perl6. That means it's not impossible to have powerful macros in Algol dialects, but it's always very difficult compared to any LISP dialect because Algol syntax seldom resemble it's own AST tree like LISP dialects do.

Sylwester
  • 47,942
  • 4
  • 47
  • 79
  • You don't need the raw ASTs with quasiquotation. – SK-logic Oct 18 '13 at 20:12
  • @SK-logic It's just half the challenge. Imagine i want `3 * 5 ¤ 2 + 2` to become `3 * something(5 2) + 2` or `loopdown x y { ... }` to become `while ( x != 0 && y != 0 ) { ... x--; y--}`. Making such macros requires modifications to the parser and precedence rules. Here is the part where the AST being different from the code makes it turn. – Sylwester Oct 18 '13 at 20:32
  • Changes to precedence rules don't necessarily mean changes to the parser. One of my toy languages uses normal math-like notation for arithmetic operations, and the +-*/ precedence is defined in its standard library using methods – Alexander Ivanov Oct 18 '13 at 21:44
  • @Sylwester, parsers are pretty flexible now (think PEG, GLR, etc.), so I see no problems here. Take a look at languages like Katahdin, Fortress and PFront. – SK-logic Oct 18 '13 at 21:48
0

My language, Slate, has a macro system at Lisp's level but manages it with Smalltalk-style syntax. In particular, we manage to be hygienic by default (but can capture) and avoiding CONS cells means that our AST nodes are data types that can define code-walking recursive methods, which means that code-walking and transformation is much easier than in Lisp.

But, plenty of newer languages (I intend to evaluate Rust and Julia) have some form of syntactic macro, so there will be more examples to choose from.