3 ms·
Re: the underlining -- no idea, just an instructional aid, I guess. Here's another example that might look "DSLy": http://www.brool.com/index.php/pattern-matc
by mquander 16y ago
Re: the underlining -- no idea, just an instructional aid, I guess.
Here's another example that might look "DSLy": http://www.brool.com/index.php/pattern-matching-in-clojure http://www.brool.com/index.php/pattern-matching-in-clojure
The pattern matching macro "match" is written entirely in Clojure, without any compiler tricks. I wish I could do the same in C#! (I'd need to have a bunch of cruft defining a predicate object with options for each match criterion.)
All of these techniques boil down to how easy it is to do two things in a language:
- To write DSL code in your structure of choice without having to cover it in a huge amount of syntax goop, e.g. the loop macro or the magic LINQ syntax.
- To analyze and transform that DSL code programmatically, in a way that's more structured than simple string manipulation, so that you can do the right thing with it.
C# 2.0 was very bad at both of these. C# 3.0 improved a lot, by adding lambda expressions for the first, and allowing you to analyze C# expressions as a syntax tree. But Clojure (& Lisp in general) is really good at both.