It struck me as the worst possible case of a stringly typed interface.
And then I realized, yes, you could provide a full strongly typed interface to the AST…. but you’d have to expose a largish bunch of compiler internals, which you’d have to learn, which would vary per implementation (D has 3 implementations).
On the other hand every D programmer already knows D and once the compiler munches on it it is strongly typed and all warnings and errors are given at compile time.
So in balance I have concluded it’s a remarkably pragmatic and effective and correct interface.
That said, I guess the down side is you are told about incorrect use of the AST as being somewhere in the mixin, rather than at the point of the code that created the string that was mixed in.
On the other hand every D programmer already knows D and once the compiler munches on it it is strongly typed and all warnings and errors are given at compile time.
that was what reconciled me to D’s string mixins too. something about them seems less principled than lisp-style macros, but if you think about what’s going on everything’s safe and well-typed at compile time.
Initially I was very anti this mixin facility.
It struck me as the worst possible case of a stringly typed interface.
And then I realized, yes, you could provide a full strongly typed interface to the AST…. but you’d have to expose a largish bunch of compiler internals, which you’d have to learn, which would vary per implementation (D has 3 implementations).
On the other hand every D programmer already knows D and once the compiler munches on it it is strongly typed and all warnings and errors are given at compile time.
So in balance I have concluded it’s a remarkably pragmatic and effective and correct interface.
That said, I guess the down side is you are told about incorrect use of the AST as being somewhere in the mixin, rather than at the point of the code that created the string that was mixed in.
that was what reconciled me to D’s string mixins too. something about them seems less principled than lisp-style macros, but if you think about what’s going on everything’s safe and well-typed at compile time.