3 ms·
It's not easy to get the point across just by reading about it. Id honestly say you should just learn some lisp and implement something cool. > I don't see why
by dunefox 4y ago
It's not easy to get the point across just by reading about it. Id honestly say you should just learn some lisp and implement something cool.
> I don't see why this would be any different than defining a function like I normally do.
Because with functions you don't define any new syntax or implement a DSL; you don't have access to the compiler during read, compilation, and run time. This allows you to easily extend the language: do you miss list comprehensions from Python? Add it yourself with a macro. Want to generate boilerplate code? Macro. Prolog compiler? Yes. Basically anything in this book: https://github.com/norvig/paip-lisp https://github.com/norvig/paip-lisp
> But why is this more productive than simply defining a "exponent()" function or something similar?
It's not just about defining a new operator, you can basically implement a DSL with C-like syntax if you want to: https://github.com/y2q-actionman/with-c-syntax https://github.com/y2q-actionman/with-c-syntax