3 ms·
I get where you're coming from, and it's something that's been debated at length. For everything-is-an-object languages like Smalltalk, the dynamic features see
by chriswarbo 8y ago
I get where you're coming from, and it's something that's been debated at length. For everything-is-an-object languages like Smalltalk, the dynamic features seem to be enough to cover lots of problems that macros are used for (e.g. https://news.ycombinator.com/item?id=14333824 https://news.ycombinator.com/item?id=14333824 ). I hear that Ruby uses monkey-patching more than other languages, which may also be an alternative (although I think macros are better than monkey-patching, since they're local transformations rather than "spooky action-at-a-distance").
Simula-style languages like C++ and Java don't offer the same sorts of dynamic features.
> Whereas (I feel that) macros are undebuggable by design.
I'd be interested to know what you mean by this. I've written macros in Emacs Lisp and Racket, and both were pretty easy to debug. In particular the tooling for each (Emacs and DrRacket) can "expand macros" to show what code a particular macro usage will turn into (at which point, we're back to debugging non-macro code; although potentially messier than we'd right by hand). In that sense they're more debuggable than functions, since we can't calculate the result of a function until run time (which is why functions need test suites, to provide a run time that's not the production application).