View mode: basic / threaded / horizontal-split · Log in · Help
October 05, 2008
Re: Positive
Denis Koroskin wrote:
> On Sun, 05 Oct 2008 20:09:25 +0400, Andrei Alexandrescu
> <SeeWebsiteForEmail@erdani.org> wrote:
> 
>> Bent Rasmussen wrote:
>>> Somewhere there is the dream of a pure function call syntax
>>>     abs(real) sqrt(abs(real) x);
>>>  Total unification. And possibly total impossibility.
>>>  Looks beautiful tho.
>>
>> It does look beautiful. It won't as soon as "!" enters the picture.
>>
>> Andrei
> 
> I second that. It also brings templates and functions closer:
> 
> int x = sqrt(42); // what is sqrt - a CT-function or a template? I don't
> care!

So in the "me" vs. "we" argument there's actually five "me"s or so. This 
has Agent Smith written all over it! :o)

Andrei
October 05, 2008
Re: Positive
On 2008-10-05 12:10:36 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail@erdani.org> said:

> I wish the dot wasn't even needed. One day I want to go over with 
> Walter about the ambiguities incurred by simply using parens.

Replacing !( with .( doesn't make things better to my eye. Having only 
parenthesis would be great though, it it could be disambiguated.

- - -

I did a quick search and replace in the D/Objective-C bridge, which is 
pretty heavy in templates, to get an idea of what it would be like 
using ".(". In many places, the result seems fine:

	const char[] encode = "{"
		~ typename.(T) ~ "="
		~ encode.(size_t) ~ encode.(ArrayType.(T)*) ~ "}";

	const char[] encode = "{"
		~ typename!(T) ~ "="
		~ encode!(size_t) ~ encode!(ArrayType!(T)*) ~ "}";

I'd be tempted to see the first version, using the .( syntax, as easier 
to read. But note that here I'm not using a dot for anything else. If I 
take these other real examples from various lines in the bridge code:

	mixin objc.bridge.ObjcSubclass.(this.stringof);

	ObjcSubclassDefs.(T).objcMethodLists ~= 
ObjcSubclassDefs.(SUPER).objcMethodLists;

	alias objc.msg.sendSuper.(objc.type.ObjcType.(R), 
objc.type.ObjcTypeTuple.(A)) msgSendSuper;

	objc.subclassinit.ObjcSubclassDefs.(typeof(this)).objcClassInit.(typeof(super))();

Here 

the dot is used to get to symbols in various modules an template 
members and in conjunction with an opening parenthesis to instanciate 
templates. This results in the strange "Template.(param).member" 
syntax. Am I the only one to find that syntax strange... if not 
misleading?

I think all these examples are much better with the current syntax, 
because defining parameters and accessing members is done with a 
totally non-overlapping syntax:

	mixin objc.bridge.ObjcSubclass!(this.stringof);

	ObjcSubclassDefs!(T).objcMethodLists ~= 
ObjcSubclassDefs!(SUPER).objcMethodLists;

	alias objc.msg.sendSuper!(objc.type.ObjcType!(R), 
objc.type.ObjcTypeTuple!(A)) msgSendSuper;

	objc.subclassinit.ObjcSubclassDefs!(typeof(this)).objcClassInit!(typeof(super))();

Basically, 

I believe the syntax we choose needs to convey that we're defining 
parameters, not accessing a member. I don't really care if we ditch 
"!(", but I think ".(" is a worse alternative.

-- 
Michel Fortin
michel.fortin@michelf.com
http://michelf.com/
October 05, 2008
Re: shouting versus dotting
Andrei Alexandrescu wrote:
> By and large we'd want seamless and smooth integration of various styles
> and techniques, wouldn't we? Shouting doesn't fit into this.

Is that a phobia? :P


-- 
Tomasz Stachowiak
http://h3.team0xf.com/
h3/h3r3tic on #D freenode
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

I guess if you want to make template look like normal code your could 
look at extending that static syntax to accept things like alias:

void FooTemplate(alias T, alias T2, static T x, T2 f)
{
...
}


//call

int value;
FooTemplate(int, int, 10, value);

//And with induction T2 can be solved so (Note: I'm considering 
induction either all that can be solved, or nothing)
FooTemplate(int, 10, value);


-Joel
October 05, 2008
Re: shouting versus dotting
Andrei Alexandrescu wrote:
> Sean Kelly wrote:
>> Andrei Alexandrescu wrote:
>>> Sean Kelly wrote:
>>>>
>>>> Will do.  It's easy enough to search-replace '!' with '.'
>>>
>>> You'll need a sed expression to not catch unary ! and != as well.
>>
>> Nah, just replace "!(" with ".("  I basically never use "!(exp)" in 
>> conditions so there should be no problems.
> 
> Well well laziness never helps.
> 
> sed --in-place -e 's/\([a-zA-Z0-9_]\)\(\s*\)!\(\s*\)(/\1\2.\3(/' *.d
> 
> Preserves whitespace used around !, too. The major problem is it will 
> transform insides of strings too. Also, won't transform instantiations
> across lines, and won't work with Unicode symbols...

I'm just talking about my own code here, not a universal conversion tool.


Sean
October 05, 2008
Re: shouting versus dotting
Janderson wrote:
> 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
> 
> I guess if you want to make template look like normal code your could 
> look at extending that static syntax to accept things like alias:
> 
> void FooTemplate(alias T, alias T2, static T x, T2 f)
> {
> ...
> }
> 
> 
> //call
> 
> int value;
> FooTemplate(int, int, 10, value);
> 
> //And with induction T2 can be solved so (Note: I'm considering 
> induction either all that can be solved, or nothing)
> FooTemplate(int, 10, value);
> 
> 
> -Joel

Walter actually went out implementing this for days and reached 
irreconcilable issues.

Andrei
October 05, 2008
Re: shouting versus dotting
Andrei Alexandrescu wrote:
> Sean Kelly wrote:
>> Andrei Alexandrescu wrote:
>>> Steven Schveighoffer wrote:
>>>> If this change is implemented, Walter is going to have a hard time 
>>>> arguing that it's not worth changing invariant to immutable...
>>>
>>> Speaking of which... guess what he just did :o).
>>
>> *dances for joy*
> 
> Well are you greased properly for giving .() a shot? :o)

I'll certainly try it.


Sean
October 05, 2008
Re: shouting versus dotting
Gregor Richards wrote:

> downs 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.
>>>
>> 
>> FWIW: I write large volumes of template code and I like the ! just fine.
>> 
> 
> Don't take this endorsement lightly. When downs says he writes large
> volumes of template code, he means volumes in the literary sense: You
> could fill a fairly-large bookshelf with his tomes of template code.

I'm sure you mean not so large tomes, but with very long lines?

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango
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.

I don't dislike !() and don't want .() 

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango
October 05, 2008
Re: shouting versus dotting
Andrei Alexandrescu wrote:
> Janderson wrote:
>> 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
>>
>> I guess if you want to make template look like normal code your could 
>> look at extending that static syntax to accept things like alias:
>>
>> void FooTemplate(alias T, alias T2, static T x, T2 f)
>> {
>> ...
>> }
>>
>>
>> //call
>>
>> int value;
>> FooTemplate(int, int, 10, value);
>>
>> //And with induction T2 can be solved so (Note: I'm considering 
>> induction either all that can be solved, or nothing)
>> FooTemplate(int, 10, value);
>>
>>
>> -Joel
> 
> Walter actually went out implementing this for days and reached 
> irreconcilable issues.
> 
> Andrei

That's a shame :(
9 10 11 12 13 14 15 16 17
Top | Discussion index | About this forum | D home