foo!(bar) ==> foo{bar}
KennyTM~
kennytm at gmail.com
Wed Oct 8 11:28:51 PDT 2008
Andrei Alexandrescu wrote:
> KennyTM~ wrote:
>> Andrei Alexandrescu wrote:
>>> Alexander Pánek wrote:
>>>> Steven Schveighoffer wrote:
>>>>> "Alexander Pánek" wrote
>>>>>> Steven Schveighoffer wrote:
>>>>>>> Everything runs together, looks like one big word. I think we
>>>>>>> need a full height character to represent template brackets,
>>>>>>> something with a lot of whitespace to separate it from the other
>>>>>>> characters.
>>>>>> Heh... sounds like !() to me! ;)
>>>>>
>>>>> *gasp* That's perfect! I say we go with it ;)
>>>>
>>>> Has my vote, for sure!
>>>
>>> One possibility to make progress would be to keep !( but allow
>>> omitting the parens when only one argument is being passed. That way
>>> many instantiations will be helped. For example, in wake of the
>>> impending demise of complex built-ins:
>>>
>>> Complex!double alpha;
>>> Complex!float[] data;
>>>
>>> That way, again, we leverage the fact that an extra symbol is needed
>>> instead of compulsively requiring it in addition of the parens.
>>>
>>> One nice thing about this change is that it keeps all code as it is,
>>> just lifts one restriction.
>>>
>>> How about that?
>>>
>>>
>>> Andrei
>>
>> vote++ for this.
>>
>> But how do templates with no arguments be called? Is “T!” valid?
>
> Offhand, that looks like it can't work, but haven't we all been wrong
> before? :o)
>
I guess no. And a template having no parameters isn't really that common
I guess? I haven't encountered one as least. I also realized if ! is a
binary operator then it shouldn't act as a postfix operator also.
(Or maybe reserve the postfix operator ! for factorial, i.e. 5! == 120
/joke)
>> If so, can these ambiguity be solved first? These are minor cases,
>> though.
>>
>> (1) opCall strikes again!
>>
>> class T(int n = 6) {
>> static int opCall (int z) {
>> writefln(z);
>> return z;
>> }
>> static char init;
>> }
>>
>> void main() {
>> auto x = T!(4).init;
>> }
>
> This is not an opCall issue. A template can alias itself to anything.
> Consider:
>
> template A(T = int)
> {
> alias foo A; // say foo is a function
> }
>
>> (2) !is
>>
>> template T() {
>> enum T = 3;
>> }
>>
>> void main () {
>> writeln(T!is 3);
>> }
>
> This is not a problem because "is" is a keyword.
>
>
> Andrei
More information about the Digitalmars-d
mailing list