foo!(bar) ==> foo{bar}

Michel Fortin michel.fortin at michelf.com
Wed Oct 8 02:44:35 PDT 2008


On 2008-10-07 22:33:32 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> I, too, think it's a nice idea. Walter, Bartosz and I discussed it a 
> while ago. There are some savings in the declaration part, and no loss 
> because you can always say typeof(arg) to figure out what the type was. 
> In general, however, with the advent of conditional templates, I 
> suspect that most templates will impose restrictions on the types of 
> their arguments and therefore will need their type names. On the 
> example given:
> 
> Range overlap(Range r1, Range r2) if (isRandomAccessRange!(Range))
> {
>      ...
> }
> 
> The signature clarifies the requirements on the type much crisper than 
> the loose, vale tudo:
> 
> auto overlap(auto r1, auto r2) { ... }
> 
> which will (1) catch every call (blech) and (2) attempt to plow through 
> its implementation and fail to compile with an uninformative message, 
> file, and line.

But, couldn't we extend auto to define named types (just like templates 
do)? Something such as:

	Range overlap(auto(Range) r1, Range r2) { ... }

Perhaps you could do this too:

	T[] foo(auto(T)[] r1, T[] r2) { ... }

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list