Hacker News new | ask | show | jobs
by jstewartmobile 3130 days ago
Yes, but will macros retain their power in a statically typed environment?
3 comments

They work pretty well in Crystal[1]. Some things are certainly a bit harder than they are in lisp/scheme but you can get a lot done with them. In crystal this is (in my experience) due to the lack of reflection support, and thus the ability to call dynamical looked up methods. Add that in and i'm pretty sure you'd remove >=90% of the current limitations, but even without that, you can get a lot done.

[1]: https://crystal-lang.org/

The only requirement to make macros work in a statically typed environment is to create a suitable type to represent the source code, and provide the operations to transform the said type. For instance, Rust has a macro system that's pretty nice to work with.

https://danielkeep.github.io/tlborm/book/README.html

They work OK in typed racket, but you will have to help the type checker a bit for the more complex macros.

And they provide utility that the type system doesn't. The for style loops are extremely useful