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

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Oct 8 11:17:47 PDT 2008


Steven Schveighoffer 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?
> 
> 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.

It does mean something in Visual Basic. I'm annoyed I even remembered 
that :o).

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

I think this will be solved once by having ! bind tighter than all of 
today's operators, which is the way it should. One advantage is that it 
makes it easier to use a template type without incurring a large change 
in the type's syntax. For example, one issue I had while working on 
complex was that changing creal to Complex!(real) is a long trip. 
Without parens, it's easier not only for Complex but others as well.

int x;

to

Safe!int x;

or:

Widget w;

to

RefCnt!Widget w;

and so on.

> 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 :(

"It'll look odd the first couple of days, then you'll get used to it." I 
seem to remember somebody said something to the same effect...


Andrei



More information about the Digitalmars-d mailing list