Proposal: Dedicated-string-mixin templates/functions

Chad J chadjoan at __spam.is.bad__gmail.com
Fri Feb 5 16:10:50 PST 2010


Nick Sabalausky wrote:
> ...

I for one really want something like that.  I think I posted a
suggestion like this as well:
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=95579

This also came up in another thread and was warmly received, in the
context of using the syntax on sql queries:
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=102085

I like your syntax too.  Mostly I just want to see this happen somehow.

I also realized such syntax allows us to do this:

	int foo = 42;
	string bar = "answer";
	
	writefln("The $bar is $foo."); // Prints "The answer is 42."

I'd love to be able to do that.

I'd settle for writefln#("The $bar is $foo."); as well if we really need
to be able to grep mixin usage.  The # could be any token of our choosing.

This all still leaves the problem of parentheses matching.  Parentheses
make a terrible nesting element.

mixin Foo!
(`
	someDslCodeHere
`);
// Yes, don't forget the terribly asymmetrical semicolon.

versus

mixin Foo!()
{
	// Valid D tokens only, and {} must be matched.
	someDslCodeHere
}

I think the latter is worth investing in as well.



More information about the Digitalmars-d mailing list