www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D2 porting notes: template function calls

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:

	// 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:


and this one also works:


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:


and neither does this one:


So it doesn't work at all for templates with explicit arguments. You'll 
need to use the regular standard template function call syntax:


 * * *

D2 allows me to change this


into this


but you can't remove the last parenthesis:

	consumeUntil!isCharOf!"/?"(input); // error

So if I have this:


and want to change isSpace to isCharOf!"/?", then you need to add an 
additional parenthesis around isCharOf!"/?" in the process.

Michel Fortin
michel.fortin michelf.com
Apr 12 2009