Can someone give some general guidelines about when to use Scheme or Racket macros and when to use functions.
If you're not creating new syntax and you're not creating side effects on variables are there cases where you would either have to (or it would be more appropriate) to use macros instead of functions?
Macros allow you to use completely different syntax. A macro invocation doesn't have to look like a function call at all, although the simplest macros often do. Also, macros are performed in a separate phase before runtime. So, if you need different syntax, or if you want macro expansion before runtime, then, well, use a macro.
In general, I'd say that if you can do it cleanly with a function, then use a function.
Matthias Felleisen has a brief discussion of this question in his Racket style guide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With