Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-08 Thread Vlad Bosinceanu
I for one cringe when I see list(), and I'd love to see [$a, $b] = array(...) become an alternative to that. Can't say I care that much about an alternative syntax for dealing with array creation, but I wouldn't mind. "[]" already suggests "array", and I guess existing developers will have no

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-08 Thread Brian Moon
But I have to ask: what's the matter. A good programming language should not force the developer to program as the language wants. A good programming language should support the developer in writing code he likes, the way he likes. So, you are new to php internal huh? =) Seriously, the langua

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-08 Thread Hartmut Holzgraefe
Mathias Bank wrote: It don't think so: PHP is a good language, but writing code in PHP is sometimes awful. This could be improved by an alternative syntax. This could help new developers who are coming from another language. This could make coding funnier for some developers. Alternative synt

[PHP-DEV] Re: Syntactic improvement to array

2007-02-08 Thread Mathias Bank
Andi Gutmans schrieb: Hi, I thought I may have brought this up a long time ago but couldn't find anything in the archives. For a long time already I've been thinking about possibly adding a new syntax for array(...) which would be shorter. I'd suggest [...]. While I am usually not in favor of

Re: [PHP-DEV] RE : [PHP-DEV] Re: Syntactic improvement to array

2007-02-06 Thread Richard Lynch
On Tue, February 6, 2007 8:17 am, LAUPRETRE François (P) wrote: >> From: Richard Lynch >> >> How many newbies will be trying: >> array[1, 2, 3]; >> and left scratching their heads when it doesn't work? > > Yes, even if I am in favor of the [] syntax, it is a good argument: > 'array[ 1, 2, 3]' can >

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-06 Thread Richard Lynch
Actually, this one was prompted by seeing a bug fix or changelog about requiring { } and : endif; to match up, rather than accepting either/or in balance. Synchronicity that I even saw that item, but there it is. I would HOPE that they'd have to balance, but if they don't for the long block synta

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-06 Thread Andrei Zmievski
Now you're just grandstanding. -Andrei On Feb 5, 2007, at 3:55 PM, Richard Lynch wrote: More edge cases: $foo = array(1, 2, 3]; $bar = [1, 2, 3); Syntax error because it's unbalancedO Or kosher, because the choice of start/end delimiters should be up to the user? Should it match whatever

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-06 Thread Andrei Zmievski
That's because you wouldn't be using those words with a newbie, if you are smart. You'd simply say "it works like list() here" and "it works like array()" here. -Andrei On Feb 5, 2007, at 3:41 PM, Richard Lynch wrote: On Mon, February 5, 2007 12:06 pm, Andrei Zmievski wrote: On Feb 4, 20

[PHP-DEV] RE : [PHP-DEV] Re: Syntactic improvement to array

2007-02-06 Thread P
> From: Richard Lynch > > How many newbies will be trying: > array[1, 2, 3]; > and left scratching their heads when it doesn't work? Yes, even if I am in favor of the [] syntax, it is a good argument: 'array[ 1, 2, 3]' can become a very common error, and not especially among newbies! Maybe I a

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Edin Kadribasic
On Feb 6, 2007, at 0:46, Richard Lynch wrote: and they don't even realize that the () doesn't mean what they think it means, and it "just works" because it's a no-op. () is not a no-op. return ($a) vs. return $a could cause PHP to corrupt memory and crash :) Edin -- Edin Kadribasic, Emini

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Sara Golemon
I would argue that list() (and [] when used like list()) should remain a terminal expression. Yes it's possible to make it non-terminal, but I don't like what the resulting syntax winds up looking like. -Sara Good question. If it's possible to make it behave this way, I don't see why not. On

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Robert Cummings
On Mon, 2007-02-05 at 17:46 -0600, Richard Lynch wrote: > > On Mon, February 5, 2007 12:05 pm, Stanislav Malyshev wrote: > >> So now we have an invisible operator with a magical symbol '[' which > >> *sometimes* means create an array, but *sometimes* means to > >> de-construct an array into individ

RE: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Mike Robinson
Richard Lynch wrote: > More edge cases: > > $foo = array(1, 2, 3]; > $bar = [1, 2, 3); > > Syntax error because it's unbalancedO > > Or kosher, because the choice of start/end delimiters should > be up to the user? > > Should it match whatever rule is in place for: > > if (...){ > endif; ec

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Richard Lynch
More edge cases: $foo = array(1, 2, 3]; $bar = [1, 2, 3); Syntax error because it's unbalancedO Or kosher, because the choice of start/end delimiters should be up to the user? Should it match whatever rule is in place for: if (...){ endif; -- Some people have a "gift" link here. Know what

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Richard Lynch
On Mon, February 5, 2007 12:05 pm, Stanislav Malyshev wrote: >> So now we have an invisible operator with a magical symbol '[' which >> *sometimes* means create an array, but *sometimes* means to >> de-construct an array into individual variables? > > Yep. We also have an invisible magical oper

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Richard Lynch
On Mon, February 5, 2007 12:06 pm, Andrei Zmievski wrote: > On Feb 4, 2007, at 8:52 PM, Richard Lynch wrote: > >> E! >> >> So now we have an invisible operator with a magical symbol '[' which >> *sometimes* means create an array, but *sometimes* means to >> de-construct an array into indivi

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Andrei Zmievski
Good question. If it's possible to make it behave this way, I don't see why not. On the other hand, if you take list(), it can't be used in RHS. -Andrei On Feb 5, 2007, at 10:28 AM, Todd Ruth wrote: Would this be legal? function f() { return [ 1, 2 ]; } $x = [ $a, $b ] = f(); In the e

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Todd Ruth
Would this be legal? function f() { return [ 1, 2 ]; } $x = [ $a, $b ] = f(); In the end, would we have...? $a = 1; $b = 2; $x = array(1,2); I'm not trying to be positive or negative about the syntax. I'm just "testing" somewhat edge cases. - Todd On Mon, 2007-02-05 at 10:06 -0800, Andre

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Stanislav Malyshev
So now we have an invisible operator with a magical symbol '[' which *sometimes* means create an array, but *sometimes* means to de-construct an array into individual variables? Yep. We also have an invisible magical operator (), which sometimes means function definition, sometimes means expres

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Andrei Zmievski
On Feb 4, 2007, at 8:52 PM, Richard Lynch wrote: E! So now we have an invisible operator with a magical symbol '[' which *sometimes* means create an array, but *sometimes* means to de-construct an array into individual variables? That's just disgusting, imho. -1 !!! The way I view [

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Richard Quadling
On 05/02/07, LAUPRETRE François (P) <[EMAIL PROTECTED]> wrote: > From: Christian Schneider [mailto:[EMAIL PROTECTED] > >> - func('foo' => $foo, 'bar' => $bar, ...) equivalent to > >> func(array('foo' => $foo, 'bar' => $bar, ...) Argh! Reading such a line, I think of named parameters, not an ar

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread ivailo91
That would be very handy. As I code frequently JavaScript and ActionScript, I will use this feature with pleasure. +2 for me :D The array(), especially for more-than-1 dimensional arrays is very cumbersome. Best Regards, Ivailo Karamanolev On Monday, February 5, 2007, 12:53:44 PM, LAUPRETRE Fra

[PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread P
> From: Christian Schneider [mailto:[EMAIL PROTECTED] > What's also beautiful about [] IMHO is the symmetry of the syntax, > list() and array() are asymmetrical which I always found inferior. Agree. +1 for me, especially for this reason, even after reading Greg's examples :) IMO, it is more i

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Lukas Kahwe Smith
Christian Schneider wrote: My personal summary of this thread is: We won't have syntactic sugar for common things like arrays, named parameter emulation and the like ever because it will be killed by the "we already have a way of doing this" and the "you cannot look it up" argument. Shame, tha

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-05 Thread Christian Schneider
Richard Lynch wrote: So now we have an invisible operator with a magical symbol '[' which *sometimes* means create an array, but *sometimes* means to de-construct an array into individual variables? The distinction you are making is from an implementation point of view. From a language users p

[PHP-DEV] Re: Syntactic improvement to array

2007-02-04 Thread Gregory Beaver
Andi Gutmans wrote: > Hi, > > I thought I may have brought this up a long time ago but couldn't find > anything in the archives. > For a long time already I've been thinking about possibly adding a new syntax > for array(...) which would be shorter. I'd suggest > [...]. While I am usually not in

Re: [PHP-DEV] Re: Syntactic improvement to array

2007-02-04 Thread Richard Lynch
On Sun, February 4, 2007 8:23 am, Christian Schneider wrote: > Andi Gutmans wrote: >> So what I'm thinking of is: >> array(1, 2, 3) == [1, 2, 3] > > I like this syntax, more conscise but still clear (and well > established > in other languages by now). > > Two more thoughts (but please don't kill A

[PHP-DEV] Re: Syntactic improvement to array

2007-02-04 Thread Sara Golemon
So what I'm thinking of is: array(1, 2, 3) == [1, 2, 3] array(1, 2, array("foo", "bar")) == [1, 2, ["foo", "bar"]] array("key" => 1, "key2" => 2) == ["key" => 1, "key2" => 2] An enthusiastic thumbs-sideways. I'll probably use this at some point, but not for anything which needs to be version a

[PHP-DEV] Re: Syntactic improvement to array

2007-02-04 Thread Christian Schneider
Andi Gutmans wrote: So what I'm thinking of is: array(1, 2, 3) == [1, 2, 3] I like this syntax, more conscise but still clear (and well established in other languages by now). Two more thoughts (but please don't kill Andi's proposal because of it, rather dismiss my comments instead ;-)): -