D2 porting notes: template function calls
Michel Fortin
michel.fortin at michelf.com
Sun Apr 12 10:06:13 PDT 2009
I've converted some of parser code to work with D2. Here are some
things I noted during the process.
First, it seems writefln is now a template. Good idea... but that broke
some of my calls to it:
writefln;
// D1: writes a new line
// D2: error, template declaration with no effect
So I need to add an empty parenthesis now.
* * *
Also, this function template works:
input.before(name);
and this one also works:
input.empty;
So it seems that contrary to writeln above the member-call syntax works
for function templates, even with no parenthesis when it requires no
function argument. That's great, but also somewhat incoherent.
Then, this call to a fucntion template doesn't work:
input.consumeOneChar!'=';
and neither does this one:
input.consumeOneChar!'='();
So it doesn't work at all for templates with explicit arguments. You'll
need to use the regular standard template function call syntax:
consumeOneChar!'='(input);
* * *
D2 allows me to change this
consumeUntil!(isCharOf!("/?"))(input);
into this
consumeUntil!(isCharOf!"/?")(input);
but you can't remove the last parenthesis:
consumeUntil!isCharOf!"/?"(input); // error
So if I have this:
consumeUntil!isSpace(input);
and want to change isSpace to isCharOf!"/?", then you need to add an
additional parenthesis around isCharOf!"/?" in the process.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list