dropping parentheses on template instantiation

Denis Koroskin 2korden at gmail.com
Mon Oct 6 12:22:10 PDT 2008


On Mon, 06 Oct 2008 23:10:02 +0400, Leandro Lucarella <llucax at gmail.com>  
wrote:

> downs, el  6 de octubre a las 17:28 me escribiste:
>> > auto v = new Vector with Stack with Tuple with (Positive with real,
>> > Matrix with real (3, 3)) ?
>>
>> auto v = new Vector of Stack of (Positive of real, Matrix of (real, 3,  
>> 3));
>>
>> Probably suboptimal. I mostly just threw that out there as a "wouldn't  
>> it be cool" to remind people that there are alternatives besides  
>> foo[SYMBOL](bar, baz)
>
> And I don't think:
> auto v = new Vector.(Stack.(Tuple.(Positive.(real), Matrix.(real))))(3,  
> 3))
> or:
> auto v = new Vector{Stack{Tuple{Positive{real}, Matrix{real}}}}(3, 3))
> or:
> auto v = new Vector at Stack@Tuple@(Positive at real, Matrix at real)(3, 3))
>
> Is particulary nice either. You should use alias when nesting too deep,
> I guess.
>

or:
auto v = new Vector@(Stack@(Tuple@(Positive at real, Matrix at real)))(3, 3)

or:
auto v = new Vector!(Stack!(Tuple!(Positive!(real), Matrix!(real))))(3, 3)

But you shouldn't write that kind of code, anyway. This is more realistic:

alias Tuple@(Positive at real, Matrix at real) MyTuple;
alias Stack at MyTuple MyStack;
alias Vector at MyStack MyVector;

But that's not a real-world example, anyway.

Could anyone convert some real-world template-heavy source-code like  
std.algorithm to all the proposed syntaxes so that we could compare them  
to each other?



More information about the Digitalmars-d mailing list