3 ms·
Or, once you have lazy evaluation (like in Haskell), for that matter.
by vog 12y ago
Or, once you have lazy evaluation (like in Haskell), for that matter.
- jlarocco 12y agoLaziness can achieve a similar thing in that case (less elegantly, IMO), but there are other uses for macros that can't be solved with laziness.
- mbrock 12y agoLook at the uses for Template Haskell, for example. That's basically Haskell's macro system. And it's used quite a lot, though it's kind of arcane. If you want to create an abstraction that defines one or several data types, you'll think hard about whether you can use some kind of type-level programming instead—but if that's not possible, or not convenient, you can use TH macros. For example, the `lens` package defines TH macros for creating special kinds of accessors that are tedious to write by hand.
- platz 12y agousing macros to deal with boilerplate, although useful, though is of a different order than things that simply cannot be expressed without macros
- wtetzner 12y agoWhich things cannot be expressed without macros? Macros run at compile time, and just output normal code in the language. I think being able to generate types is a very useful and important use of macros. In fact, (depending on whether or not your macros can have side effects) you could use macros to implement something like F#'s type providers.
- kazinator 12y agoSearch down for my comment which contains the substring: "if I have a non-strictly evaluated language with higher order functions, do I still need macros?"