View mode: basic / threaded / horizontal-split · Log in · Help
October 05, 2008
Re: shouting versus dotting
Andrei Alexandrescu 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.

Sean has a point. Templates are not runtime constructs. So a clear 
distinction between instantiating a function with a given type and just 
calling a function that has fixed argument types and a fixed return type 
 is necessary. The exclamation mark gives us this clear distinction and 
has served well in terms of readability for me, especially because it 
jumps out — not because it’s an exclamation mark, thus having a meaning 
in natural language, but rather just because of its form. A straight 
vertical line with a dot underneath it. That just works perfectly well 
as seperator between identifier/type and type argument.

Also, you might want to consider changing your font if exclamation marks 
jump at you so intensively. ;)
October 05, 2008
Re: Positive
dsimcha wrote:
> == Quote from Andrei Alexandrescu (SeeWebsiteForEmail@erdani.org)'s article
>> Jason House wrote:
>>> Andrei Alexandrescu Wrote:
>>>> Positive.(real) sqrt(Positive.(real) x);
>>> Ummm... That's not even the correct signature for square root. It
>>> should accept non negative numbers.
>> Rats. I was thinking positive means >= 0 and strictly positive means >
>> 0. According to Wikipedia, positive really means strictly positive and
>> the longer-to-type NonNegative should be used instead :o|. For such a
>> simple concept, a short and sweet name is pivotal. If there are any
>> ideas for a better choice, please make them known.
>> Andrei
> 
> Maybe create the templates as a back end using whatever name, and then create
> typedefs/aliases for ufloat, udouble, ureal?  This would definitely be consistent
> with ints and easy to remember.

I think that's a great idea. So, the question becomes: how do people 
feel about using ufloat, udouble, and ureal?

Andrei
October 05, 2008
Re: shouting versus dotting
dsimcha wrote:
> == Quote from Andrei Alexandrescu (SeeWebsiteForEmail@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
October 05, 2008
Re: shouting versus dotting
Alexander Pánek wrote:
> Andrei Alexandrescu 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.
> 
> Sean has a point. Templates are not runtime constructs. So a clear 
> distinction between instantiating a function with a given type and just 
> calling a function that has fixed argument types and a fixed return type 
>  is necessary.

Why? This sounds objective, so you better back it up. Au contraire, I 
see absolutely, but absolutely no need for a distinction. If it weren't 
for syntactic difficulties, to me using straight parentheses for 
template instantiation would have been the perfect choice. (How many 
times did you just forget the "!"? I know I often do. Why? Because most 
of the time it's not even needed.)

> The exclamation mark gives us this clear distinction and 
> has served well in terms of readability for me, especially because it 
> jumps out — not because it’s an exclamation mark, thus having a meaning 
> in natural language, but rather just because of its form. A straight 
> vertical line with a dot underneath it. That just works perfectly well 
> as seperator between identifier/type and type argument.

I believe the clear distinction is not only unnecessary, but 
undesirable. We should actively fight against it.

> Also, you might want to consider changing your font if exclamation marks 
> jump at you so intensively. ;)

I use Vera, probably the best code font I've ever had.


Andrei
October 05, 2008
Re: Positive
Andrei Alexandrescu wrote:
> dsimcha wrote:
>> == Quote from Andrei Alexandrescu (SeeWebsiteForEmail@erdani.org)'s 
>> article
>>> Jason House wrote:
>>>> Andrei Alexandrescu Wrote:
>>>>> Positive.(real) sqrt(Positive.(real) x);
>>>> Ummm... That's not even the correct signature for square root. It
>>>> should accept non negative numbers.
>>> Rats. I was thinking positive means >= 0 and strictly positive means >
>>> 0. According to Wikipedia, positive really means strictly positive and
>>> the longer-to-type NonNegative should be used instead :o|. For such a
>>> simple concept, a short and sweet name is pivotal. If there are any
>>> ideas for a better choice, please make them known.
>>> Andrei
>>
>> Maybe create the templates as a back end using whatever name, and then 
>> create
>> typedefs/aliases for ufloat, udouble, ureal?  This would definitely be 
>> consistent
>> with ints and easy to remember.
> 
> I think that's a great idea. So, the question becomes: how do people 
> feel about using ufloat, udouble, and ureal?

I’d even suggest putting those into the language as primitive types — I 
just figured out they are not. Puzzled me a bit.
October 05, 2008
Re: shouting versus dotting
Andrei Alexandrescu 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.

Not only that, but typing it is annoying. First you need to put the 
right pinky on the shift key, which is a long reach; then you need to 
put the left pinky on the 1 key, which is a long reach. Then you need to 
move your left pinky all the way back to the left shift key, which is a 
short reach, and move your right ring finger up to the 9 key.

It's a lot of reaching and back and forth.

But I don't favor '.' since it's already used.
October 05, 2008
shouting versus dotting
Steven Schveighoffer wrote:
> "Walter Bright" wrote
>> Steven Schveighoffer wrote:
>>> It's very alarming to me that something like this just has no problem 
>>> getting in the language without community feedback.
>> It's there at the moment so we can look at it and see if we like it. I 
>> know Andrei likes it. Anyhow, this is the opportunity for community 
>> feedback.
> 
> Well, here is my feedback.
> 
> First, I hate it when D has two ways of doing something.  For example, C 
> style array declarations, or function pointers.  But those have good 
> reasons.  We want the new style because it's unambiguous and context-free, 
> but we want the old style to allow easy porting of C code.

I agree that D should not gratuitously define two ways of doing something.

> But this change has no qualities I can see except that Andrei thinks it 
> looks better (at least, that's the only reason he's given).

Believes, not thinks :o).

> There are not 
> compatibility issues with C or some other language, it's just a new syntax 
> that looks different.  Are there problems with the original !()?  Please 
> give a reason for this addition besides asthetics, and then we can discuss 
> the merits.  Or if the community overwhelmingly loves this new syntax, I 
> guess that's a good reason.  Otherwise, I think it should be rejected on the 
> simple principle of not fixing things that aren't broken.

There are no objective differences, only the subjective arguments I 
brought based on linguistic conotations of "!". And actually I didn't 
come up with that argument - it literally came to me. Word followed by 
exclamation mark. Our brains are wired to interpret that as an 
exclamation. If it's frequent enough in code, it becomes really jarring.

The one way to figure whether you'd aesthetically like something or not 
is to try it on some code. Unfortunately, that's not yet possible until 
the next release (Walter was kind enough to send me an alpha for a test 
drive). So my only request is kindly please hold off judgment until you 
can play with the notation and see how you feel.


Andrei
October 05, 2008
Re: shouting versus dotting
Christopher Wright wrote:
> Andrei Alexandrescu 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.
> 
> Not only that, but typing it is annoying. First you need to put the 
> right pinky on the shift key, which is a long reach; then you need to 
> put the left pinky on the 1 key, which is a long reach. Then you need to 
> move your left pinky all the way back to the left shift key, which is a 
> short reach, and move your right ring finger up to the 9 key.
> 
> It's a lot of reaching and back and forth.
> 
> But I don't favor '.' since it's already used.

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!

Andrei!
October 05, 2008
Re: shouting versus dotting
Andrei Alexandrescu Wrote:

> dsimcha wrote:
> > == Quote from Andrei Alexandrescu (SeeWebsiteForEmail@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.
October 05, 2008
Re: Positive
I prefer your suggestion of ufloat/udouble/ureal to Positive,
and I would definitely use these. I already use unsigned integer
types a LOT, even more than signed ones.

Have you thought how (and if) auto-casting would work?

As far as template instantiation goes, my feeling is that
the "." is too easily confused with method invocation. I
know you are trying to make them look more similar, but
for we mere mortals that don't do much template programming,
we need something that stand out more. Something less alarming
than "!" would be ok, so long as there was ONLY ONE way.

Graham.
1 2 3 4 5 6 7
Top | Discussion index | About this forum | D home