shouting versus dotting

Chris R. Miller lordsauronthegreat at gmail.com
Sun Oct 5 17:12:44 PDT 2008


superdan wrote:
> Andrei Alexandrescu Wrote:
> 
>> dsimcha wrote:
>>> == Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
>>>> The problem I see with "!" as a template instantiation is not technical.
>>>> I write a fair amount of templated code and over years the "!" did not
>>>> grow on me at all. I was time and again consoled by Walter than one day
>>>> that will happen, but it never did. I also realized that Walter didn't
>>>> see a problem with it because he writes only little template code.
>>>> I didn't have much beef with other oddities unique to D. For example, I
>>>> found no problem accommodating binary "~" and I was wondering what makes
>>>> "!" different. I was just looking at a page full of templates and it
>>>> looked like crap.
>>>> One morning I woke up with the sudden realization of what the problem
>>>> was: the shouting.
>>>> In C, "!" is used as a unary operator. That may seem odd at first, but
>>>> it nevers follows a word so it's tenuous to associate it with the
>>>> natural language "!". In D, binary "!" _always_ follows a word, a name,
>>>> something coming from natural language. So the conotation with
>>>> exclamation jumps at you.
>>>> That's why I find the choice of "!" poor. I believe it can impede to
>>>> some extent acquisition of templates by newcomers, and conversely I
>>>> believe that using .() can make templates more palatable. I tried using
>>>> ".()" in my code and in only a couple of days it looked and felt way
>>>> better to me. Based on that experience, I suggest that "!()" is dropped
>>>> in favor of ".()" for template instantiation for D2.
>>>> Sean's argument that "The exclamation mark signifies an assertion of
>>>> sorts" is exactly where I'd want templates not to be: they should be
>>>> blended in, not a hiccup from normal code. Serious effort has been, and
>>>> still is, made in D to avoid shell-shocking people about use of
>>>> templates, and I think ".()" would be a good step in that direction.
>>>> Andrei
>>> Personally, I think that ".()" looks a little too much like a normal
>>> function/method call.  The "!()" syntax looks just different enough to make it
>>> easy to keep straight in my head that stuff with the "!" is a compile-time
>>> construct and stuff without it can be evaluated at runtime.
>> I'm arguing we _should_ make template code look like "normal" code, 
>> whatever "normal" is :o). We _should_ strive for "quiet" templates.
>>
>> You know what annoys the living heebiejeebies out of me? Nested template 
>> instantiations.
>>
>> This!(That!(TheOther!(crap)))
>>
>> I have a ton + change of those. In superdan's words: intercourse that.
>>
>>
>> Andrei
> 
> im a bit drunk. but im much obliged since my name was mentioned n all.
> 
> ! pisses me off too. i have an opinion. walter looked at unary ops that can be binary ops. first tilde. pulled tat off. ten he wanted the template thing. only 1 left was !. so he put that at work. right walt?
> now i never like ! because of nother reason. i always forget to put it. and yes it's not needed. i look @ code its unambig. then wtf do i need that crap !
> 
> anyhoo would be great if ! goes away. to hell with it. need to try asdad.(asdasd) to see how it feels. and yeah they all jump andreis neck whever he posts any. or walts. its funny. hold them guns folks. can i delete this later i wonder.

I live in California.  Legally I cannot own any gun that could 
conceivably hurt someone when misused under the proper situations.  =/

I was never particularly annoyed by the !() syntax, but then again I 
have not written much template code.  I can count the number of template 
classes I have written on one hand.

I am deeply concerned about the proposed .() syntax, however, since (to 
me) it's too similar to a function call.  This lack of finding some kind 
of counterproposal left me studying my keyboard for any unused 
characters that could become a symbol.  I saw these symbols that I could 
remember no existing use for:

@, #, $, `

I'm favorable to the # symbol.  So a template would look like 
foo#(int)(bar).

To me the # symbol looks like it could be two Latin 't' characters (not 
to be confused with the Greek Tau 'T', which is different).  Thus one 
could remember the mnemonic "template" with two t's for the # symbol.

Just a countersuggestion, I haven't really looked through specifications 
or anything to verify the unused status of any of those symbols.



More information about the Digitalmars-d mailing list