Looking for Details On Recent Changes
Chris Nicholson-Sauls
ibisbasenji at gmail.com
Wed Apr 11 15:32:57 PDT 2007
Dan wrote:
> Xinok Wrote:
>
>> I'm looking for details on two changes in particular.
>>
>> First comes from 1.011, being the macro keyword. I can't find anything
>> about it, and I have no idea how to use it.
>>
>> Second comes from 1.010:
>> >> Added template partial specialization derived from multiple parameters.
>> I don't understand what this means exactly?
>
> Aww shit. D's getting macros? I was hoping to avoid having to read those.
Yes macros, but nothing like C pre-processor macros. No #DEFINE's in sight. From the
prior discussions on this, they will appear something more like this:
macro default_gettor (name, var) {
typeof(var) name () { return var; }
}
class Foo {
private int _bar ;
this (int barval) { _bar = barval; }
default_gettor(bar, _bar);
}
Contrived example, but you get the notion of what it will make possible. Presumably they
could also be used with Tuples via a wrapping template... which means you could write a
template-macro pair that cough up an entire module for, say, a variant type with some
simple introspection capabilities, which can have new types/behaviors added to it just by
adding one relatively simple line to a macro call or template instantiation at the bottom
of the module. (At least, that's a rough description of something I plan to do with them.)
-- Chris Nicholson-Sauls
More information about the Digitalmars-d
mailing list