Thanks for posting this! While we’ve known about this for years in the Dylan community, we forget that this stuff is new to a lot of people still. :)
I really enjoy some of the things that we can do with the Dylan macro system. Some wonderful examples of this can be found in our binary-data system:
define abstract binary-data <icmp-echo-message> (<icmp-frame>)
field code :: <unsigned-byte> = 0;
field checksum :: <2byte-big-endian-unsigned-integer> = 0;
field identifier :: <2byte-big-endian-unsigned-integer> = 42;
field sequence-number :: <2byte-big-endian-unsigned-integer> = 0;
field icmp-data :: <raw-frame>;
end;
The extensions that this paper brings would be very useful. We’ve heard / been told that much of the machinery for this is already available within the compiler, but we don’t currently know how to make this visible on the user side of the compilation process. (The people who wrote this paper and our macro expander have long since moved on.)
That said, the facilities described by this paper are widely used in the implementation of the Open Dylan compiler and some of the compiler libraries (like our C-FFI).
I also recently wrote and extended some similar code to support our Objective C / Dylan bridge that will be in our next release. This allows us to have code like:
All of that said … macros can be quite difficult to work with. They often have relatively poor error handling, can make editor integration more difficult, make things like auto-indenting more difficult.
I think I’d prefer to solve a problem using metaprogramming rather than macros, if possible, only falling back to macros if necessary. Though of course many languages don’t support either, let alone give you a choice. Ruby doesn’t have macros, despite the efforts of Caleb Clausen.
The additional burden on anyone trying to understand the code. Metaprogramming imposes that burden too, but it can’t add new syntax, so a person (or software tool for that matter) has one less reason to complain ;)
Thanks for posting this! While we’ve known about this for years in the Dylan community, we forget that this stuff is new to a lot of people still. :)
I really enjoy some of the things that we can do with the Dylan macro system. Some wonderful examples of this can be found in our binary-data system:
The extensions that this paper brings would be very useful. We’ve heard / been told that much of the machinery for this is already available within the compiler, but we don’t currently know how to make this visible on the user side of the compilation process. (The people who wrote this paper and our macro expander have long since moved on.)
That said, the facilities described by this paper are widely used in the implementation of the Open Dylan compiler and some of the compiler libraries (like our C-FFI).
I also recently wrote and extended some similar code to support our Objective C / Dylan bridge that will be in our next release. This allows us to have code like:
All of that said … macros can be quite difficult to work with. They often have relatively poor error handling, can make editor integration more difficult, make things like auto-indenting more difficult.
Macros are not the only way to construct this kind of DSL. Way back in 2005 I developed a similar binary data DSL in ruby using metaprogramming:
https://github.com/vjoel/bit-struct#example
I think I’d prefer to solve a problem using metaprogramming rather than macros, if possible, only falling back to macros if necessary. Though of course many languages don’t support either, let alone give you a choice. Ruby doesn’t have macros, despite the efforts of Caleb Clausen.
[Comment removed by author]
The additional burden on anyone trying to understand the code. Metaprogramming imposes that burden too, but it can’t add new syntax, so a person (or software tool for that matter) has one less reason to complain ;)
I’d really like to be wrong about this…