3 ms·
> So for me, Common Lisp has actually shrunk without losing any functionality. This is not possible in languages without macros. Such languages are indeed doome
by lmm 11y ago
> So for me, Common Lisp has actually shrunk without losing any functionality. This is not possible in languages without macros. Such languages are indeed doomed to either grow forever, or change in non-backwards-compatible ways (e.g. Python3). But with macros you can shrink a language as well as grow it.
Not true. If a language has adequate general constructs then you can replace language features with ordinary code written in the language. E.g. in Scala no-one uses "return" any more, because you can get the same functionality (in a better / more consistent way) using library types - just ordinary classes with ordinary methods, no macros needed.
- lisper 11y ago> in Scala no-one uses "return" any more Huh??? Does Scala even have a "return" statement? I can't find it in the docs.
- draven 11y agoThere is: http://scala-lang.org/files/archive/spec/2.11/06-expressions.html#return-expressions http://scala-lang.org/files/archive/spec/2.11/06-expressions... The general consensus is: don't use it.
- lisper 11y agoAh, there it is. OK, so I'm still confused. > you can get the same functionality (in a better / more consistent way) using library types RETURN is a control construct. How do you emulate a control construct using types?
- lmm 11y agoIn a language with first-class functions, control constructs can be replaced by polymorphic methods - see smalltalk for the ultimate version of this. In scala the idiomatic way to do "short-circuit the rest of this in some cases" is usually for/yield with a type like scalaz's \/.
- sklogic 11y agoOk. Replace an optimising static BNF compiler macro with "classes" and "methods".
- lmm 11y agoA lot of things that seem like they would need compiler support actually don't. Look at Spire.
- sklogic 11y agoWith macros you've got a compiler support for anything you can imagine. And with macros you implement your DSLs as compilers, not interpreters, which is a huge advantage: you've got static verification, you've got any performance you like, and compilers are so much, much easier to implement than interpreters. So what's the point in doing the wrong, slow and error-prone thing instead of fast, easy and robust one? If you're talking about this spire ( https://github.com/non/spire https://github.com/non/spire ) than it's using generics (i.e., poor man macros) and some real macros too, apparently.
- lmm 11y ago> With macros you've got a compiler support for anything you can imagine. Most of what you can imagine isn't useful or maintainable. Good tools should have more structure to guide you. > And with macros you implement your DSLs as compilers, not interpreters I'm not suggesting interpreters. If anything I'd say that macros - running arbitrary code at compile time - are more interpreterlike than what I'm describing. > it's using generics (i.e., poor man macros) Well if you're going to define every useful language feature as "macros" then of course you need macros to implement anything! But most of us consider generics to be different from macros.
- sklogic 11y ago> Good tools should have more structure to guide you. It's not possible to have more solid and strict structure than with macro-based DSLs. > I'm not suggesting interpreters. You do. Either macros or interpreters. There is no other way. > are more interpreterlike than what I'm describing. You did not describe your approach to a problem yet. How would you implement an optimising BNF-based eDSL without macros? Spir and similar things are a totally different topic. > But most of us consider generics to be different from macros. Most people have absolutely no idea what metaprogramming is and how to implement DSLs properly. I would not refer to an opinion of a crowd.