Scriptlike v0.9.4 - Perl-like interpolated strings, full examples and more.

H. S. Teoh via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Fri Sep 25 14:28:50 PDT 2015


On Fri, Sep 25, 2015 at 02:14:30PM +0200, Jacob Carlborg via Digitalmars-d-announce wrote:
> On 2015-09-25 02:15, H. S. Teoh via Digitalmars-d-announce wrote:
> 
> >I wanted to work on it, but haven't actually gotten to it yet.
> >Basically, the idea is relatively simple:
> >
> >	// compile-time variant
> >	void writefln(string format="", A...)(A args)
> >		if (format.length > 0)
> >	{
> >		... // implementation here
> >	}
> >
> >	// runtime variant
> >	void writefln(string format="", A...)(A args)
> >		if (format.length == 0 && args.length > 0 &&
> >			is(typeof(args[0]) == string))
> >	{
> >		... // current implementation
> >	}
> 
> Not sure why you need to complicate it with template constraints. Just
> overload the function?
[...]

It's to work around a dmd bug that doesn't allow overloads between
templates and non-templates.  But I just checked, looks like that bug
may have been fixed since, so now the following overloads would work:

	void writefln(string format, A...)(A args) { ... } // current
	void writefln(A...)(string format, A args) { ... } // new


T

-- 
Don't drink and derive. Alcohol and algebra don't mix.


More information about the Digitalmars-d-announce mailing list