dropping parentheses on template instantiation

Denis Koroskin 2korden at gmail.com
Mon Oct 6 12:55:51 PDT 2008


On Mon, 06 Oct 2008 23:39:44 +0400, KennyTM~ <kennytm at gmail.com> wrote:

> Denis Koroskin wrote:
>> 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?
>
>    NxNHelper!(F).For!(Args).Result
>
> (taken from std.algorithm.reduce.) Then we have
>
>
>    NxNHelper of F.For of Args.Result
>
>    NxNHelper at F.For@Args.Result
>

You gotta get used to it..

>    NxNHelper{F}.For{Args}.Result
>

And this one is my favorite!

>
> --
>
>    Tuple!(Iterator!(Range1), Iterator!(Range2))
>
> (taken form std.algorithm.mismatch.) Then we have
>
>    Tuple of (Iterator of Range1, Iterator of Range2)
>     /* or omit Tuple of, as suggested by downs */
>
>    Tuple@(Iterator at Range1, Iterator at Range2)
>
>    Tuple{Iterator{Range1}, Iterator{Range2}}

Last two are equally good to me.



More information about the Digitalmars-d mailing list