[Proposal]

Rémy Mouëza Rémy_member at pathlink.com
Sat Jun 17 07:20:54 PDT 2006


>> 
>> http://www.digitalmars.com/d/template.html
>> If there's only a single declaration, you can even write:
>> 
>> T sqr(T) ( T x )
>> {
>>     return x*x;
>> }
>> 
>> Which is already in the language and even shorter than your proposal ;)
>> This is the same for class templates.
>
>Well, besides that it isn't documented (as far as I can see)
>I think it's rather confusing 
>(two sequential pairs of parameters in parentheses - I a more complicated case
>you really don't tell whether it is template or not at the first glance).
>It's different from the class case where parameter list in parentheses in
>umabiguous.
>
>I've thought of that variant too but it seems to me that it's less readable.
>
>Another variant maybe is to insert "!" before template parameters list in a
>declaration too:
>
>----------------------------
>T sqr!(T) ( T x )
>{
>     return x*x;
>}
>----------------------------
>
>-- 
>AKhropov

The "identifier!( T )" syntax is used for instanciating templates. Personnally,
I think it might be a little bit confusing in a declaration. What about making
it look like a parameterized argument list, by just moving the place where stand
the "!" or use an other, more recognizable symbol ?
T sqr ( T )!( T x ) { return x * x ; }
T sqr ( T ):( T x ) ...
T sqr:( T ) ( T x ) ...

Of course, those syntax proposal are suggestion for people who, unlike me, are
not yet satisfied with the current syntax. 





More information about the Digitalmars-d mailing list