View mode: basic / threaded / horizontal-split · Log in · Help
October 05, 2008
Re: shouting versus dotting
Jarrett Billingsley wrote:
> On Sun, Oct 5, 2008 at 12:06 AM, Andrei Alexandrescu
> <SeeWebsiteForEmail@erdani.org> wrote:
>> 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.
> 
> Long argument short:  I don't mind !() at all, and changing it to .()
> seems like a pointless pedanticism.  But since you're the one
> suggesting it, there's a very good chance of it getting into the
> language (if it hasn't already), so there's not much use arguing
> against it.

It won't make it unless others try it and find it palatable too. But 
please let's try it first.

Also, I'm much less keen on introducing .() than on ousting !(), which I 
believe was a very poor choice. So I suggest we all explore other syntax 
choices until we find something that we can show to the world with a 
straight face.


Andrei
October 05, 2008
Re: shouting versus dotting
Lionello Lunesu wrote:
> Michel Fortin wrote:
>> On 2008-10-05 01:14:17 -0400, Andrei Alexandrescu 
>> <SeeWebsiteForEmail@erdani.org> said:
>>
>>> I don't favor "." any more than the next guy, but I am glad there is 
>>> awareness of how unfit a choice "!" is. If you have any ideas, please 
>>> post them! Ah! I! Exclaimed! Again!
>>
>> Hum, I don't think we have much choice, it'll have to be something in 
>> this lot:
>>
>>     Positive!(real)(joke);
>>     Positive.(real)(joke);
>>     Positive#(real)(joke);
>>     Positive@(real)(joke);
>>     Positive&(real)(joke);
>>     Positive`(real)(joke);
>>     Positive´(real)(joke);
>>     Positive^(real)(joke);
>>     Positive¨(real)(joke);
>>     Positive\(real)(joke);
> 
> Positive$(real)(joke);
> 
> Does D have a use for # at the moment? I'm surprised it wasn't used for 
> array length instead of $.

I considered # too. It's a bit "fat", but you know what, I'd rather deal 
with a fella with a slight weight problem than one who's shouting all 
the time.

Andrei
October 05, 2008
Re: shouting versus dotting
KennyTM~ wrote:
> Andrei Alexandrescu wrote:
>> Michel Fortin wrote:
>>> On 2008-10-05 01:14:17 -0400, Andrei Alexandrescu 
>>> <SeeWebsiteForEmail@erdani.org> said:
>>>
>>> -- snip --
>>>
>>> Or we could use special delimiter characters:
>>>
>>>     Positive<real>(joke);
>>>     Positive“real”(joke);
>>>     Positive«real»(joke);
>>>     Positive#real@(joke);
>>>
>>> Each having its own problem though.
>>>
>>> My preference still goes to "!(".
>>
>> There was also Positive{real}(joke), with which I couldn't find an 
>> ambiguity.
>  >
> 
> Ohhhh. Why isn't it considered then? (Suppose we already knew Positive 
> is not a keyword and not preceded by the keywords struct, class, etc.)

I believe it should be considered. At some point there was discussion on 
accepting a last parameter of delegate type outside the function parens. 
The idea was to allow user-defined code to define constructs similar to 
e.g. if and foreach.

But I think that has many other problems (one of which is that the 
delegate can't reasonably specify parameters), so we can safely discount 
that as a problem.

I'd want to give it a try. How do others feel about Template{arguments}?


Andrei
October 05, 2008
Re: Positive
Andrei Alexandrescu wrote:

>> I'll just insert my usual "real is not a type, but an alias"...
> 
> I thought it's a real type. No?

No, "real" is an alias for "largest hardware implemented floating point
size". So it can be anything from 64 to 80 to 96 to 128 bits in size...

I dubbed the two underlying IEEE types "extended" (80) and "quad" (128),
as in "*** precision" (just like single precision and double precision)

>> At least udouble is easier to understand than Positive.(double)
> 
> The comparison was with Positive!(double). I'm Positive!

:-)

--anders
October 05, 2008
Re: shouting versus dotting
Adam D. Ruppe wrote:
> On Sun, Oct 05, 2008 at 09:29:37AM -0500, Andrei Alexandrescu wrote:
>> Heh. So this change should come together with abolishing goto :o).
> 
> Noooooooooooooooooooooooooo!

No worries. Goto to Walter is what money is to Swiss banks. :o)

Andrei

P.S. I have one goto in my code too.
October 05, 2008
Re: Positive
Anders F Björklund wrote:
> Andrei Alexandrescu wrote:
> 
>>> I'll just insert my usual "real is not a type, but an alias"...
>>
>> I thought it's a real type. No?
> 
> No, "real" is an alias for "largest hardware implemented floating point
> size". So it can be anything from 64 to 80 to 96 to 128 bits in size...

Yes, it's a type of unknown width. But it's a distinct type nontheless 
for all I know. For example, even on a system that had 64-bit math, real 
would be a distinct type from double even if they had the same size and 
behavior.

Andrei
October 05, 2008
Re: Positive
Andrei Alexandrescu wrote:

>> No, "real" is an alias for "largest hardware implemented floating point
>> size". So it can be anything from 64 to 80 to 96 to 128 bits in size...
> 
> Yes, it's a type of unknown width. But it's a distinct type nontheless 
> for all I know. For example, even on a system that had 64-bit math, real 
> would be a distinct type from double even if they had the same size and 
> behavior.

Right, for all practical purposes it maps straight to C's "long double".

--anders
October 05, 2008
Re: shouting versus dotting
Andrei Alexandrescu wrote:
> I'd want to give it a try. How do others feel about Template{arguments}?

I’m not sure. It looks somehow better when nesting template arguments, 
but {} doesn’t quite fit in as some kind of argument in a C-style 
language like D, I think.

Template{int}(); // Looks awkward.
October 05, 2008
Re: shouting versus dotting
"Andrei Alexandrescu" wrote
> KennyTM~ wrote:
>> Andrei Alexandrescu wrote:
>>> Michel Fortin wrote:
>>>> On 2008-10-05 01:14:17 -0400, Andrei Alexandrescu 
>>>> <SeeWebsiteForEmail@erdani.org> said:
>>>>
>>>> -- snip --
>>>>
>>>> Or we could use special delimiter characters:
>>>>
>>>>     Positive<real>(joke);
>>>>     Positive"real"(joke);
>>>>     Positive«real»(joke);
>>>>     Positive#real@(joke);
>>>>
>>>> Each having its own problem though.
>>>>
>>>> My preference still goes to "!(".
>>>
>>> There was also Positive{real}(joke), with which I couldn't find an 
>>> ambiguity.
>>  >
>>
>> Ohhhh. Why isn't it considered then? (Suppose we already knew Positive is 
>> not a keyword and not preceded by the keywords struct, class, etc.)
>
> I believe it should be considered. At some point there was discussion on 
> accepting a last parameter of delegate type outside the function parens. 
> The idea was to allow user-defined code to define constructs similar to 
> e.g. if and foreach.
>
> But I think that has many other problems (one of which is that the 
> delegate can't reasonably specify parameters), so we can safely discount 
> that as a problem.
>
> I'd want to give it a try. How do others feel about Template{arguments}?

I like it much better than .()

But I'd still vote for keeping !(), as I have no problems with it.

-Steve
October 05, 2008
Re: shouting versus dotting
Andrei Alexandrescu wrote:
> KennyTM~ wrote:
>> Andrei Alexandrescu wrote:
>>> Michel Fortin wrote:
>>>> On 2008-10-05 01:14:17 -0400, Andrei Alexandrescu 
>>>> <SeeWebsiteForEmail@erdani.org> said:
>>>>
>>>> -- snip --
>>>>
>>>> Or we could use special delimiter characters:
>>>>
>>>>     Positive<real>(joke);
>>>>     Positive“real”(joke);
>>>>     Positive«real»(joke);
>>>>     Positive#real@(joke);
>>>>
>>>> Each having its own problem though.
>>>>
>>>> My preference still goes to "!(".
>>>
>>> There was also Positive{real}(joke), with which I couldn't find an 
>>> ambiguity.
>>  >
>>
>> Ohhhh. Why isn't it considered then? (Suppose we already knew Positive 
>> is not a keyword and not preceded by the keywords struct, class, etc.)
> 
> I believe it should be considered. At some point there was discussion on 
> accepting a last parameter of delegate type outside the function parens. 
> The idea was to allow user-defined code to define constructs similar to 
> e.g. if and foreach.
> 

Probably use

  func () {
    // some delegates
  }

? Just like what has been done to class invariants. But this may cause 
ambiguity if the 1st parameter of func is optional...

>
> But I think that has many other problems (one of which is that the 
> delegate can't reasonably specify parameters), so we can safely discount 
> that as a problem.
> 
> I'd want to give it a try. How do others feel about Template{arguments}?
> 
> 
> Andrei
6 7 8 9 10 11 12 13 14
Top | Discussion index | About this forum | D home