News for hackers. Stuff that matters.
Re:Why didn't Common Lisp fix the world? by sklogic on Tuesday May 17, 2016 @05:25AM (#11712224)
Norvig nailed it - instead of being sissy about macros altogether the mainstream languages must rather enforce a certain discipline. And the rules for the macros done right are very simple and well known.
Re:Why didn't Common Lisp fix the world? by jeffreyrogers on Tuesday May 17, 2016 @08:12AM (#11712906)
Honestly, I don't get the fuss about macros. I haven't seen many (any?) use cases for them, where they don't make the code harder to understand while doing something that isn't already straightforward in the base language.
Re:Why didn't Common Lisp fix the world? by sklogic on Tuesday May 17, 2016 @08:57AM (#11713178)
> Honestly, I don't get the fuss about macros.

DSLs are an ultimate solution. And DSLs are best implemented with macros.

> where they don't make the code harder to understand

Macros are there to make code easier to understand.

I just explained it in detail elsewhere: https://news.ycombinator.com/item?id=11705170

Re:Why didn't Common Lisp fix the world? by jeffreyrogers on Tuesday May 17, 2016 @11:01AM (#11714213)
Yes, I get theory, but I haven't seen much use for them in practice.
Re:Why didn't Common Lisp fix the world? by sklogic on Tuesday May 17, 2016 @11:09AM (#11714280)
It puzzles me too, that people are not using the most powerful development technique.

I cannot imagine not using macros for pretty much everything I do.

Re:Why didn't Common Lisp fix the world? by wry_discontent on Tuesday May 17, 2016 @03:47PM (#11716740)
I've written a handful of Clojure and Emacs Lisp, but I don't get macros. How is a macro different than passing a quoted list to a function?

Maybe I just need to start slinging more lisp, but I don't see how they're particularly different from functions.

Re:Why didn't Common Lisp fix the world? by sklogic on Tuesday May 17, 2016 @05:51PM (#11717791)
> How is a macro different than passing a quoted list to a function?

Macro is a function that is executed in compile time. Think of it as a way of extending your compiler with new functionality. For example, your language does not have support for pattern matching originally. It's not a problem - you can define a macro that adds such a functionality to a language. You cannot do it with functions - it must be compiled and optimised before execution, and functions cannot introduce new identifiers into a scope.

Another simple example would be something like list comprehensions - also introducing variables and also requiring optimisations in compile time.

And at extreme level, macros can be used to turn your host language into something totally different. Not just add few new features, but turn it into another language. Lisp can become an ML or Haskell, or Prolog, or Java, or whatever else you can imagine. Macros can change syntax, can implement new semantics. None of it can be done with just functions.