This post has NOT been accepted by the mailing list yet.
I started writing macros this weekend to convert between units of measurement as in Frink language - degrees and radians, seconds and milliseconds, etc. - using a subset of units adequate for 2D game development. I define the units as TypeDefs of Int and Float, and as long as I can present the correct nominal type to the macros, they will automatically convert between the various units, or give a compile-time error if invalid units are presented.
The problem is that these types are hard to usefully extend into other code without breaking static enforcement. In making a vector class based on one of the distance units, I find myself introducing every single function as a macro that performs typechecking. Because I can't preserve the nominal type in regular functions, I can't easily abstract away the process of checking and conversion - the macros have to be pushed down into the "top level" of everything that needs to observe these types. So although I only have a few classes that need to know about these types, the code size for them is getting extremely large for the amount of functionality presented.
Is there a clean solution for this that I'm missing? I am new to macros.