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

Steven Schveighoffer schveiguy at yahoo.com
Wed Oct 8 10:25:09 PDT 2008


"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?

Can't say I love the way it looks, but I can't really find anything 
technically wrong with it.  Although you know my position on optional 
parentheses :)  Except here, x!y doesn't mean something in another language.

The only thing I have against it is what other people have stated about your 
Complex!float[].

It looks ambiguous, even though the precedence could be well-defined.  Some 
other odd things to think about, what do they mean?:

a!b op c

where op is + - / * ~ || && | &

struct a(int x) {...}
a!-5 b;
a!~5 b;

struct a(bool x) {...}
bool b;
a!!b c;

I don't think I'll get used to it :(

-Steve 





More information about the Digitalmars-d mailing list