February 27, 2006
On Mon, 27 Feb 2006 22:25:37 +1100, Nils Hensel <nils.hensel@web.de> wrote:

> Lionello Lunesu schrieb:
>> Talking of which: when is that "auto" ambiguity going to be resolved? (I still prefer "var" to "auto"
>
> This would get my vote as well. "var" is far more intuitive and it would be similar to DScript. I don't think there's an obvious connection between "auto" and the data type of a variable.
>

Thanks! There has been something bugging me about this since it appeared and that is it. True its an 'auto' but an auto what? Auto scope? Auto Type? Auto mobile? Auto initialization? Simply, 'auto' is way too ambiguous. At least 'var' is more focused.

-- 
Derek Parnell
Melbourne, Australia
February 27, 2006
Georg Wrede wrote:
> Better 'fess up front: the intent of this post is to once and for all murder, pulverize and extradite the new if construct.
> 
> Consider:
> 
>         if (m; std.regexp.search("abcdef", "b(c)d"))
>         {
>             writefln("[%s]", m.pre);      // prints [a]
>             writefln("[%s]", m.post);     // prints [ef]
>             writefln("[%s]", m.match(0)); // prints [bcd]
>             writefln("[%s]", m.match(1)); // prints [c]
>             writefln("[%s]", m.match(2)); // prints []
>         }
> 
> Flauting this around has shown that experienced programmers have a hard time figuring out what is going on here.
> 
> Consider:
> 
>         if (m; std.regexp.search("abcdef", "b(c)d"))
> 
> Most everybody take it for granted that here is a typo, the '(m;' must be the result of a sloppy copy-paste.
> 
> And in the previous case the theories ranged from all kinds of behind-the-scenes magic.
> 
> Now consider:
> 
>         if (Regexp m = std.regexp.search("abcdef", "b(c)d"))
>         {
>             writefln("[%s]", m.pre);      // prints [a]
>             writefln("[%s]", m.post);     // prints [ef]
>             writefln("[%s]", m.match(0)); // prints [bcd]
>             writefln("[%s]", m.match(1)); // prints [c]
>             writefln("[%s]", m.match(2)); // prints []
>         }
> 
> Flaunting this around (to both the original programmers, and also to virgin victims), gave the same, _immediate_ comment from everybody: "Ah, that's neat!"

I would say extend the with(...) construct to silently fail( and take an else clause ) if the object of the with statement is null.

with( Regexp m = std.regexp.search(...) )
{
  ...
}
else { ... }

Of course foreach is still preferred for multi returned values.

-DavidM

February 27, 2006
> with( Regexp m = std.regexp.search(...) )
> {
>   ...
> }
> else { ... }

I like that "else"! Sure makes that code nicer than the following (equivalent) code:

# Regexp m = std.regexp.search(...);
# if (m) {
#   with(m) {
#     ...
#   }
# }
# else { ... }

L.


February 27, 2006
Georg Wrede wrote:
> Better 'fess up front: the intent of this post is to once and for all murder, pulverize and extradite the new if construct.
> 
> Consider:
> 
>         if (m; std.regexp.search("abcdef", "b(c)d"))
<snip>
> Now consider:
> 
>         if (Regexp m = std.regexp.search("abcdef", "b(c)d"))
>         {
>             writefln("[%s]", m.pre);      // prints [a]
>             writefln("[%s]", m.post);     // prints [ef]
>             writefln("[%s]", m.match(0)); // prints [bcd]
>             writefln("[%s]", m.match(1)); // prints [c]
>             writefln("[%s]", m.match(2)); // prints []
>         }
> 
> Flaunting this around (to both the original programmers, and also to virgin victims), gave the same, _immediate_ comment from everybody: "Ah, that's neat!"

It should be quite straightforward to support both syntaxes.  People could have the choice of declaration syntax to match for, or semicolon syntax to match foreach.

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
February 27, 2006
Derek Parnell wrote:
> On Mon, 27 Feb 2006 22:25:37 +1100, Nils Hensel <nils.hensel@web.de> wrote:
> 
>> Lionello Lunesu schrieb:
>>
>>> Talking of which: when is that "auto" ambiguity going to be resolved?  (I still prefer "var" to "auto"
>>
>>
>> This would get my vote as well. "var" is far more intuitive and it would  be similar to DScript. I don't think there's an obvious connection  between "auto" and the data type of a variable.
>>
> 
> Thanks! There has been something bugging me about this since it appeared  and that is it. True its an 'auto' but an auto what? Auto scope? Auto  Type? Auto mobile? Auto initialization? Simply, 'auto' is way too  ambiguous. At least 'var' is more focused.

I agree.
February 27, 2006
I'll vote against it because I don't understand the value of

if (m; search("abcdef", "BcdasdfD"))

over

if (Regexp m = search("abcdef", "BcdasdfD") ) .

Maybe someone can enlighten me?


Georg Wrede wrote:
> Better 'fess up front: the intent of this post is to once and for all murder, pulverize and extradite the new if construct.
> 
> Consider:
> 
>         if (m; std.regexp.search("abcdef", "b(c)d"))
>         {
>             writefln("[%s]", m.pre);      // prints [a]
>             writefln("[%s]", m.post);     // prints [ef]
>             writefln("[%s]", m.match(0)); // prints [bcd]
>             writefln("[%s]", m.match(1)); // prints [c]
>             writefln("[%s]", m.match(2)); // prints []
>         }
> 
> Flauting this around has shown that experienced programmers have a hard time figuring out what is going on here.
> 
> Consider:
> 
>         if (m; std.regexp.search("abcdef", "b(c)d"))
> 
> Most everybody take it for granted that here is a typo, the '(m;' must be the result of a sloppy copy-paste.
> 
> And in the previous case the theories ranged from all kinds of behind-the-scenes magic.
> 
> Now consider:
> 
>         if (Regexp m = std.regexp.search("abcdef", "b(c)d"))
>         {
>             writefln("[%s]", m.pre);      // prints [a]
>             writefln("[%s]", m.post);     // prints [ef]
>             writefln("[%s]", m.match(0)); // prints [bcd]
>             writefln("[%s]", m.match(1)); // prints [c]
>             writefln("[%s]", m.match(2)); // prints []
>         }
> 
> Flaunting this around (to both the original programmers, and also to virgin victims), gave the same, _immediate_ comment from everybody: "Ah, that's neat!"
February 27, 2006
Derek Parnell escribió:
> On Mon, 27 Feb 2006 22:25:37 +1100, Nils Hensel <nils.hensel@web.de> wrote:
> 
>> Lionello Lunesu schrieb:
>>> Talking of which: when is that "auto" ambiguity going to be resolved? (I still prefer "var" to "auto"
>>
>> This would get my vote as well. "var" is far more intuitive and it would be similar to DScript. I don't think there's an obvious connection between "auto" and the data type of a variable.
>>
> 
> Thanks! There has been something bugging me about this since it appeared and that is it. True its an 'auto' but an auto what? Auto scope? Auto Type? Auto mobile? Auto initialization? Simply, 'auto' is way too ambiguous. At least 'var' is more focused.
> 
> --Derek Parnell
> Melbourne, Australia

I prefer auto for auto typing rather than for auto destruction. Preferences...

-- 
Carlos Santander Bernal
February 27, 2006
On Mon, 27 Feb 2006 17:14:28 -0500, Carlos Santander wrote:

> Derek Parnell escribió:
>> On Mon, 27 Feb 2006 22:25:37 +1100, Nils Hensel <nils.hensel@web.de> wrote:
>> 
>>> Lionello Lunesu schrieb:
>>>> Talking of which: when is that "auto" ambiguity going to be resolved? (I still prefer "var" to "auto"
>>>
>>> This would get my vote as well. "var" is far more intuitive and it would be similar to DScript. I don't think there's an obvious connection between "auto" and the data type of a variable.
>>>
>> 
>> Thanks! There has been something bugging me about this since it appeared and that is it. True its an 'auto' but an auto what? Auto scope? Auto Type? Auto mobile? Auto initialization? Simply, 'auto' is way too ambiguous. At least 'var' is more focused.
>> 
>> --Derek Parnell
>> Melbourne, Australia
> 
> I prefer auto for auto typing rather than for auto destruction. Preferences...

But that's my point ... 'auto' by itself is ambiguous and for a first-timer to understand it depends somewhat on one's preconceptions and preferences.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
28/02/2006 9:37:39 AM
February 27, 2006
I think its short for 'auto' deduction ?

'var' gets my vote

Derek Parnell wrote:
> On Mon, 27 Feb 2006 22:25:37 +1100, Nils Hensel <nils.hensel@web.de> wrote:
> 
>> Lionello Lunesu schrieb:
>>
>>> Talking of which: when is that "auto" ambiguity going to be resolved?  (I still prefer "var" to "auto"
>>
>>
>> This would get my vote as well. "var" is far more intuitive and it would  be similar to DScript. I don't think there's an obvious connection  between "auto" and the data type of a variable.
>>
> 
> Thanks! There has been something bugging me about this since it appeared  and that is it. True its an 'auto' but an auto what? Auto scope? Auto  Type? Auto mobile? Auto initialization? Simply, 'auto' is way too  ambiguous. At least 'var' is more focused.
> 
February 27, 2006
Nice, this gets my vote.

David Medlock wrote:
> Georg Wrede wrote:
> 
>> Better 'fess up front: the intent of this post is to once and for all murder, pulverize and extradite the new if construct.
>>
>> Consider:
>>
>>         if (m; std.regexp.search("abcdef", "b(c)d"))
>>         {
>>             writefln("[%s]", m.pre);      // prints [a]
>>             writefln("[%s]", m.post);     // prints [ef]
>>             writefln("[%s]", m.match(0)); // prints [bcd]
>>             writefln("[%s]", m.match(1)); // prints [c]
>>             writefln("[%s]", m.match(2)); // prints []
>>         }
>>
>> Flauting this around has shown that experienced programmers have a hard time figuring out what is going on here.
>>
>> Consider:
>>
>>         if (m; std.regexp.search("abcdef", "b(c)d"))
>>
>> Most everybody take it for granted that here is a typo, the '(m;' must be the result of a sloppy copy-paste.
>>
>> And in the previous case the theories ranged from all kinds of behind-the-scenes magic.
>>
>> Now consider:
>>
>>         if (Regexp m = std.regexp.search("abcdef", "b(c)d"))
>>         {
>>             writefln("[%s]", m.pre);      // prints [a]
>>             writefln("[%s]", m.post);     // prints [ef]
>>             writefln("[%s]", m.match(0)); // prints [bcd]
>>             writefln("[%s]", m.match(1)); // prints [c]
>>             writefln("[%s]", m.match(2)); // prints []
>>         }
>>
>> Flaunting this around (to both the original programmers, and also to virgin victims), gave the same, _immediate_ comment from everybody: "Ah, that's neat!"
> 
> 
> I would say extend the with(...) construct to silently fail( and take an else clause ) if the object of the with statement is null.
> 
> with( Regexp m = std.regexp.search(...) )
> {
>   ...
> }
> else { ... }
> 
> Of course foreach is still preferred for multi returned values.
> 
> -DavidM
>