Re: [PHP-DEV] Proposal: Array syntax

2003-11-06 Thread Andi Gutmans
At 02:07 AM 11/6/2003 +0100, Christian Schneider wrote:
George Schlossnagle wrote:
George (thinking [] is pretty but disliking alternative syntaxes)
Ok, let me recap my short visit on this mailing list:
1) Dangling commas in function calls were considered bloat
No, not bloat. I was worried that they might bite us at some point in the 
future if/when we want to add some features to function calls. I don't see 
this as a crucial feature.

2) Adding the local vars to debug_backtrace() was silently ignored
Because I think most people probably don't have much of an opinion on this. 
Personally, it could maybe be an optional parameter.

3) A prettier array syntax was discarded because it's an alternative
I don't think it has been discarded yet. I usually object to this kind of 
stuff but I do see that it improves the readability of code enormously 
(IMO). I think the answers on this list were split. How about you write a 
realistic sample script both ways and post it to the list. I think the 
examples people gave on this list were not realistic. Give me any language 
feature and I can show you how ugly it can be made :)

On the other hand Sara Golemon wrote:
 It's Perlish and ugly.  It is *not* PHP syntax.
while e.g. private, catch, throw, final were introduced which are 
Javaesque and ugly. They are *not* PHP spirit of a simple language. But I 
didn't complain.
These features are a necessity for PHP to continue to compete in the web 
application development market.

After all this I guess I have to maintain my own PHP branch and hope for 
PHP6 to address some of my issues. Or switch to another language at some 
point, because a language to me is a tool, not a religion.
I don't think your issues are that serious that they require you to switch 
to a different language.

Andi

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-06 Thread Stig S. Bakken
On Wed, 2003-11-05 at 17:48, Andi Gutmans wrote:
 At 11:48 AM 11/5/2003 -0500, Ilia Alshanetsky wrote:
 On November 5, 2003 11:21 am, you wrote:
   Well, like I said before, I am not sure this is a clear case of that.  I'm
   probably the biggest defender around of the no-magic rule, but [] does
   imply something array-related to most people, so I think the magic part is
   much smaller than in other proposals we have seen.
 
 Right now [] could either be an array element or an offset. Now it can either
 be an array element or a string offset or an attempt to create a new array.
 Individually it may be fine, but I am certain we'll end up with bug reports
 of people trying to do $a = $b[1,2,3]; (copied from your resonse ;) ) and
 similar. Of course someone would then want to do $a[1,2,3] = [3,4,5]; and
 we're happily on our road to obfuscation.
 
 I mean c'mon, is 5 characters that much of a problem and is absolute code
 clarity not worth those 5 characters? Character efficiency is done in Perl,
 where you can do things like ~= and @_, but that makes Perl code naturally
 obfuscated and I do not think that's a good way to go.
 
 I don't believe in saving characters. You probably know that I tend to 
 prefer looong meaningful names and not have all sorts of magic. I think 
 in this case, it's not a matter of saving the typing as it looks much 
 better and IMO is more intuitive.
 Anyway, it's no biggy and if most people here think it shouldn't be added 
 then that's fine with me.

I don't see a reason for introducing [] for arrays.  And this is coming
from the guy who came up with the original ({ }) syntax in
3.0-pre-alpha, which was replaced with array() for readability.

Let's sum up the pros and cons:

Pros: sexiness?

Cons: another BC issue, syntax obfuscation, potential grammar conflicts

I used to not like array() because it was too verbose, but today I think
it's great because its meaning is very crisp and clear when you read the
code.  Screwing up readable syntax in favor of sexiness is Perl's
business, not PHP's.

 - Stig

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-06 Thread Kouber Saparev
Perlish or not could not be a real reason for adding or not adding a feature
in PHP. The important thing here is if it fits to the language concept or
not.

Kouber

Sara Golemon [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 FWIW- (And I understand I'm late chiming in on this thread)

  I'm -1 on this syntax.

  It's Perlish and ugly.  It is *not* PHP syntax.

 -Sara

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] Proposal: Array syntax

2003-11-06 Thread Mike Robinson

Kouber Saparev wrote:
 Perlish or not could not be a real reason for adding or not 
 adding a feature in PHP. The important thing here is if it
 fits to the language concept or not.

Indeed, and IMHO it does, much like

($a==$b)?...

fits in quite well as an alternative to

if ($a==$b)...

It is an alternative syntax that makes things more readable
and easier to use. Not an awful lot of magic, sexiness, or
character savings involved.

Best Regards
Mike Robinson

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-06 Thread Andi Gutmans
At 09:58 AM 11/6/2003 +0100, Stig S. Bakken wrote:
Let's sum up the pros and cons:

Pros: sexiness?

Cons: another BC issue, syntax obfuscation, potential grammar conflicts
Just to be more accurate there are no BC issues and as far as I know, there 
aren't any grammar conflicts.

Andi

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-06 Thread Alexey Trunyov
Mike Robinson wrote:

Perlish or not could not be a real reason for adding or not 
adding a feature in PHP. The important thing here is if it
fits to the language concept or not.


Indeed, and IMHO it does, much like

($a==$b)?...

fits in quite well as an alternative to

if ($a==$b)...

It is an alternative syntax that makes things more readable
and easier to use. Not an awful lot of magic, sexiness, or
character savings involved.
The ternary conditional operator is not an alternative to
if-then-else construct because it always evaluates to some boolean while 
the latter doesn't evalute to anything because it's just control of 
execution structure.

As for discussed array syntaxes they always evaluate to the same result 
given the same input values. So they're equal.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DEV] Proposal: Array syntax

2003-11-06 Thread Ford, Mike [LSS]
On 05 November 2003 17:19, Marco Tabini wrote:

 Ford, Mike [LSS] wrote:
  On 05 November 2003 17:06, Marco Tabini contributed these pearls of
  wisdom: 
  
  
   Christian Schneider wrote:
   
Marco Tabini wrote:


 $a = [[1,2,3],[1=[1,3,2,2], a=[[1,2,3,4],4,[1,2]]];


$a = array(array(1,2,3),array(1=array(1,3,2,2),
a=array(array(1,2,3,4),4,array(1,2)));

   
   Besides my previous points, something even more abominable:
   
   $a = [1,2,$b[11]];
   
   Is that confusing enough for you? ;-)
  
  
  What's confusing about it?
  
 
 The fact that $b[11] references an item of an array, while
 [1,2,$b[11]] assigns values to the array $a.

That's not confusing -- at least no more so than the different meanings of -
in $b = -$a and $b = $c - $a.

  The fact that you (and,
 probably, most of us) can't tell right off the bat

Bzzt!  Wrong!  It was because I *could* tell right off the bat exactly what
it meant that I asked why it was confusing.

  is a clear sign
 that this is a bad idea, because it's ambiguous and confusing.

And again, wrong assumption -- I asked what's confusing because to me it
looks completely unambiguous and totally clear.

 The same line using the current syntax, btw, would have looked like
 this: 
 
 $a = array (1,3,$b[11]);

Well, I can see true enough that that has the same meaning, but for me it's
harder to read and interpret.  I see the () first and start assuming it's a
function, before my eyes and brain have time to digest that the name of the
function is array -- result: a moment's confusion whilst I deal with the
ambiguity of using function syntax for a language construct.  With the []
syntax, I see the square brackets and they immediately shout ARRAY
CONSTRUCTOR at me -- result: instant understanding and I'm on to the next
line of code in a flash.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] Proposal: Array syntax

2003-11-06 Thread Ford, Mike [LSS]
On 05 November 2003 18:39, Andrei Zmievski wrote:

 On Wed, 05 Nov 2003, Ford, Mike   [LSS] wrote:
  
  I don't think the number of characters is the main issue here --
  it's about having a *nicer* set of characters.  Personally, I'd be
  still be in favour (although not quite as much) if the proposed
  syntax were [[[1,2,3]]] -- for me, it's about having a syntax that
  shouts *ARRAY* rather than whispers it. 
 
 And array() steps too softly for you?

In comparison to [], yes.  I mean, I've got used to array() and all, and I'd
happily carry on using it if the consensus goes that way, but I'd also
switch all my scripts to [] in a twinkling if it became permitted.

(Hell, let's face it, you can get used to anything if it's the right tool
for the job -- and almost anything's an improvement over spending an
afternoon counting parentheses in a LISP program, curly brackets in a B
program, or the number of implied REFs in an Algol68 type declaration...!)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] EOT (was RE: [PHP-DEV] Proposal: Array syntax)

2003-11-06 Thread Sascha Schumann
Please move this thread to private email.

- Sascha

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] EOT (was RE: [PHP-DEV] Proposal: Array syntax)

2003-11-06 Thread Andi Gutmans
Sascha,

I don't think it's a private matter. Feel free to delete the emails with 
this subject when they come in.

Andi

At 01:30 PM 11/6/2003 +0100, Sascha Schumann wrote:
Please move this thread to private email.

- Sascha

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] EOT (was RE: [PHP-DEV] Proposal: Array syntax)

2003-11-06 Thread Sascha Schumann
On Thu, 6 Nov 2003, Andi Gutmans wrote:

 Sascha,

 I don't think it's a private matter.

If there was anything constructive in that long thread of I
like it -- no, I don't! I might agree with you, but given
the current contents, the noise exceeds the useful debate by
far.

- Sascha

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-06 Thread Stig S. Bakken
On Thu, 2003-11-06 at 13:04, Andi Gutmans wrote:
 At 09:58 AM 11/6/2003 +0100, Stig S. Bakken wrote:
 Let's sum up the pros and cons:
 
 Pros: sexiness?
 
 Cons: another BC issue, syntax obfuscation, potential grammar conflicts
 
 Just to be more accurate there are no BC issues and as far as I know, there 
 aren't any grammar conflicts.

With BC issues I mean that there will be one more hurdle preventing code
originally written with PHP 5 to run on PHP 4.

 - Stig

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Andi Gutmans
Hi Christian,

Personally I don't like having two ways of doing things. It makes it harder 
for people to read scripts.
However, I think the proposed syntax is significantly more elegant than 
today's array() which makes me think twice about the idea and possibly 
making an exception to the rule. I think it'll improve the look of PHP 
scripts. Also I think people calling methods using call_user_method([$obj, 
method]); will find it sexier than the array() syntax.
I guess I think it'd be interesting to see what other's think. Also, 
another point to check is if list() can also be converted into [] because 
having a hybrid wouldn't be too nice.

Andi

At 12:33 AM 11/5/2003 +0100, Christian Schneider wrote:
I propose to add an alternative (backward compatible) short array creation 
syntax:
$a = [ 1, 2, 3 ]; and $a = [ 'a' = 42, 'b' = foo ];

It can also be used in function calls:
img(['src' = logo.gif, 'alt' = Logo]);
Reason behind this change: Arrays are used a lot and should therefore have 
as little syntactic overhead as possible. And I think the short syntax is 
also easier to read and write.

A patch for the parser is trivial and is attached for Zend2.

Note: I checked the newsgroup archive but couldn't find a discussion about 
this. After not hearing back about my proposed enhancement to 
debug_backtrace() and the dangling comma for function call parameters 
being rejected I wonder if I'm using the right mailing list for this :-)

- Chris

Index: Zend/zend_language_parser.y
===
RCS file: /repository/ZendEngine2/zend_language_parser.y,v
retrieving revision 1.127
diff -u -r1.127 zend_language_parser.y
--- Zend/zend_language_parser.y 19 Oct 2003 08:38:48 -  1.127
+++ Zend/zend_language_parser.y 4 Nov 2003 23:32:12 -
@@ -581,6 +581,7 @@
|   '@' { zend_do_begin_silence($1 TSRMLS_CC); } expr { 
zend_do_end_silence($1 TSRMLS_CC); $$ = $3; }
|   scalar  { $$ = $1; }
|   T_ARRAY '(' array_pair_list ')' { $$ = $3; }
+   |   '[' array_pair_list ']' { $$ = $2; }
|   '`' encaps_list '`' { zend_do_shell_exec($$, 
$2 TSRMLS_CC); }
|   T_PRINT expr  { zend_do_print($$, $2 TSRMLS_CC); }
 ;

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Michael Walter
Very cool.

How about supporting .. syntax, btw. as in [1..3] or [a..z]? Might 
no be the worth, just thinking out loud ;)

Christian Schneider wrote:
I propose to add an alternative (backward compatible) short array 
creation syntax:
$a = [ 1, 2, 3 ]; and $a = [ 'a' = 42, 'b' = foo ];

It can also be used in function calls:
img(['src' = logo.gif, 'alt' = Logo]);
Reason behind this change: Arrays are used a lot and should therefore 
have as little syntactic overhead as possible. And I think the short 
syntax is also easier to read and write.

A patch for the parser is trivial and is attached for Zend2.

Note: I checked the newsgroup archive but couldn't find a discussion 
about this. After not hearing back about my proposed enhancement to 
debug_backtrace() and the dangling comma for function call parameters 
being rejected I wonder if I'm using the right mailing list for this :-)

- Chris



Index: Zend/zend_language_parser.y
===
RCS file: /repository/ZendEngine2/zend_language_parser.y,v
retrieving revision 1.127
diff -u -r1.127 zend_language_parser.y
--- Zend/zend_language_parser.y 19 Oct 2003 08:38:48 -  1.127
+++ Zend/zend_language_parser.y 4 Nov 2003 23:32:12 -
@@ -581,6 +581,7 @@
|   '@' { zend_do_begin_silence($1 TSRMLS_CC); } expr { 
zend_do_end_silence($1 TSRMLS_CC); $$ = $3; }
|   scalar  { $$ = $1; }
|   T_ARRAY '(' array_pair_list ')' { $$ = $3; }
+   |   '[' array_pair_list ']' { $$ = $2; }
|   '`' encaps_list '`' { zend_do_shell_exec($$, $2 
TSRMLS_CC); }
|   T_PRINT expr  { zend_do_print($$, $2 TSRMLS_CC); }
 ;

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Michael Walter
Very cool.

How about supporting .. syntax, btw. as in [1..3] or [a..z]? Might 
no be the worth, just thinking out loud ;)
might not be worth it..
Christian Schneider wrote:

I propose to add an alternative (backward compatible) short array 
creation syntax:
$a = [ 1, 2, 3 ]; and $a = [ 'a' = 42, 'b' = foo ];

It can also be used in function calls:
img(['src' = logo.gif, 'alt' = Logo]);
Reason behind this change: Arrays are used a lot and should therefore 
have as little syntactic overhead as possible. And I think the short 
syntax is also easier to read and write.

A patch for the parser is trivial and is attached for Zend2.

Note: I checked the newsgroup archive but couldn't find a discussion 
about this. After not hearing back about my proposed enhancement to 
debug_backtrace() and the dangling comma for function call parameters 
being rejected I wonder if I'm using the right mailing list for this :-)

- Chris



Index: Zend/zend_language_parser.y
===
RCS file: /repository/ZendEngine2/zend_language_parser.y,v
retrieving revision 1.127
diff -u -r1.127 zend_language_parser.y
--- Zend/zend_language_parser.y19 Oct 2003 08:38:48 -1.127
+++ Zend/zend_language_parser.y4 Nov 2003 23:32:12 -
@@ -581,6 +581,7 @@
 |'@' { zend_do_begin_silence($1 TSRMLS_CC); } expr { 
zend_do_end_silence($1 TSRMLS_CC); $$ = $3; }
 |scalar{ $$ = $1; }
 |T_ARRAY '(' array_pair_list ')' { $$ = $3; }
+|'[' array_pair_list ']' { $$ = $2; }
 |'`' encaps_list '`'{ zend_do_shell_exec($$, $2 
TSRMLS_CC); }
 |T_PRINT expr  { zend_do_print($$, $2 TSRMLS_CC); }
 ;



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Kouber Saparev
Your idea is even cooler...;)

I would like to have these in PHP.

Kouber

Michael Walter [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Very cool.

 How about supporting .. syntax, btw. as in [1..3] or [a..z]? Might
 no be the worth, just thinking out loud ;)

 Christian Schneider wrote:
  I propose to add an alternative (backward compatible) short array
  creation syntax:
  $a = [ 1, 2, 3 ]; and $a = [ 'a' = 42, 'b' = foo ];
 
  It can also be used in function calls:
  img(['src' = logo.gif, 'alt' = Logo]);
 
  Reason behind this change: Arrays are used a lot and should therefore
  have as little syntactic overhead as possible. And I think the short
  syntax is also easier to read and write.
 
  A patch for the parser is trivial and is attached for Zend2.
 
  Note: I checked the newsgroup archive but couldn't find a discussion
  about this. After not hearing back about my proposed enhancement to
  debug_backtrace() and the dangling comma for function call parameters
  being rejected I wonder if I'm using the right mailing list for this :-)
 
  - Chris
 
 
  
 
  Index: Zend/zend_language_parser.y
  ===
  RCS file: /repository/ZendEngine2/zend_language_parser.y,v
  retrieving revision 1.127
  diff -u -r1.127 zend_language_parser.y
  --- Zend/zend_language_parser.y 19 Oct 2003 08:38:48 - 1.127
  +++ Zend/zend_language_parser.y 4 Nov 2003 23:32:12 -
  @@ -581,6 +581,7 @@
   | '@' { zend_do_begin_silence($1 TSRMLS_CC); } expr
 zend_do_end_silence($1 TSRMLS_CC); $$ = $3; }
   | scalar { $$ = $1; }
   | T_ARRAY '(' array_pair_list ')' { $$ = $3; }
  + | '[' array_pair_list ']' { $$ = $2; }
   | '`' encaps_list '`' { zend_do_shell_exec($$, $2 TSRMLS_CC); }
   | T_PRINT expr  { zend_do_print($$, $2 TSRMLS_CC); }
   ;
 
 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Christian Schneider
Andi Gutmans wrote:
I guess I think it'd be interesting to see what other's think. Also, 
another point to check is if list() can also be converted into [] 
because having a hybrid wouldn't be too nice.
Having list() work the same way would be very sexy indeed:
[$a, $b] = [$b, $a];
To be honest I never really liked the distinction between list() and 
array().

Using [] for arrays is also consistent with dereferenceing arrays and 
therefore shouldn't confuse people really.

My first shot at extending the parser to allow [] for list() failed 
though as both T_LIST and T_ARRAY are used in expr_without_variable. But 
I'm sure you could find a clever way around this, my knowledge of yacc 
is still limited :-)

But even without [] for list() I think [] for array() would be nice ;-)

- Chris

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Ford, Mike [LSS]
On 05 November 2003 08:50, Andi Gutmans contributed these pearls of wisdom:

 At 12:33 AM 11/5/2003 +0100, Christian Schneider wrote:
 I propose to add an alternative (backward compatible) short
 array creation syntax: $a = [ 1, 2, 3 ]; and $a = [ 'a' =
 42, 'b' = foo ];  
 
 Personally I don't like having two ways of doing things. It
 makes it harder
 for people to read scripts.
 However, I think the proposed syntax is significantly more
 elegant than
 today's array() which makes me think twice about the idea and
 possibly making an exception to the rule. I think it'll
 improve the 
 look of PHP
 scripts. Also I think people calling methods using
 call_user_method([$obj,
 method]); will find it sexier than the array() syntax.
 I guess I think it'd be interesting to see what other's think.

I would be greatly in favour of the [] construct.  I've used a number of
languages over the years which feature this kind of syntax (a current
example being JavaScript), and always found the array() syntax clumsy by
comparison.

(And, to answer another thread, personally I don't think it's any more
magic than the use of [] to access individual array elements -- and the
two are so clearly related that once you know what one does it would be easy
to guess the meaning of the other.)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Cesare D'Amico
On Wednesday 05 November 2003 09:49, Andi Gutmans wrote:
 However, I think the proposed syntax is significantly more elegant than
 today's array() which makes me think twice about the idea and possibly
 making an exception to the rule. I think it'll improve the look of PHP
 scripts. Also I think people calling methods using call_user_method([$obj,
 method]); will find it sexier than the array() syntax.

This syntax is really pythonian... I can see python programmers prouding 
themselves as trend makers in programming languages ;)

Ciao
 ce
-- 
L'Informatica riguarda i computer tanto quanto l'astronomia riguarda i 
telescopi
   -- E. W. Dijkstra

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Alexey Trunyov
Andi Gutmans wrote:

Personally I don't like having two ways of doing things. It makes it 
harder for people to read scripts.
It looks like the one way of doing two separate things.
I mean that semanics of two usages of square brackets as operator is 
inverse depending on whether it is used in unary or binary form.

Being unary, square brackets operator is array constructor.
And being applied to left-side variable it becomes a reference to an 
array element.

These two usages do some sort of inverse stuff.

BTW is [1][0]==1 true with the proposed syntax?

However, I think the proposed syntax is significantly more elegant than 
today's array() which makes me think twice about the idea and possibly 
making an exception to the rule. I think it'll improve the look of PHP 
scripts. Also I think people calling methods using 
call_user_method([$obj, method]); will find it sexier than the array() 
syntax.
I guess I think it'd be interesting to see what other's think. Also, 
another point to check is if list() can also be converted into [] 
because having a hybrid wouldn't be too nice.
That was what I think although I am not the one to listened to.

Andi

At 12:33 AM 11/5/2003 +0100, Christian Schneider wrote:

I propose to add an alternative (backward compatible) short array 
creation syntax:
$a = [ 1, 2, 3 ]; and $a = [ 'a' = 42, 'b' = foo ];

It can also be used in function calls:
img(['src' = logo.gif, 'alt' = Logo]);
Reason behind this change: Arrays are used a lot and should therefore 
have as little syntactic overhead as possible. And I think the short 
syntax is also easier to read and write.

A patch for the parser is trivial and is attached for Zend2.

Note: I checked the newsgroup archive but couldn't find a discussion 
about this. After not hearing back about my proposed enhancement to 
debug_backtrace() and the dangling comma for function call parameters 
being rejected I wonder if I'm using the right mailing list for this :-)

- Chris
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Antony Dovgal
On Wed, 05 Nov 2003 19:34:52 +0700
Alexey Trunyov [EMAIL PROTECTED] wrote:

 Andi Gutmans wrote:
 
  Personally I don't like having two ways of doing things. It makes it 
  harder for people to read scripts.
 
 It looks like the one way of doing two separate things.

No, it looks like someone trying to turn PHP into Perl (or Python).
Personally I would prefer not to import Perl-style  Python-style syntax to PHP.
These things already work well(yes, you can think, that array()  range() are ugly, 
but they are already used in tonns of projects) and I can't see any reasons to change 
such fundamental things just because version number changes from 4 to 5.
If you really like this syntax - use Perl or Python, or whatever you want, but I 
really can't understand why PHP should allow you to use this syntax too.

---
WBR,
Antony Dovgal aka tony2001
[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Ilia Alshanetsky
I do not like the new syntax at all. If anything it seems rather unnatural and 
what do you save, typing of 5 characters that makes it clear that this is an 
array to even the most novice of users? It certainly not going to make the 
code any faster and if anything will only add confusion.

Firm -1.

Ilia

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Marco Tabini
Hi Andi, Christian--

From a logical standpoint, I think this could be very confusing. To me, 
for one, square brackets imply reference, not assignment. Taking 
something that means take something out of the array and now using it 
to mean put something in the array makes the language a bit less 
self-consistent... and, as Rasmus mentioned, less readable. Conciveness 
is not everything--one also has to be able to understand his own code 
after he's written it :-)

Cheers,

Marco

Andi Gutmans wrote:
Hi Christian,

Personally I don't like having two ways of doing things. It makes it 
harder for people to read scripts.
However, I think the proposed syntax is significantly more elegant than 
today's array() which makes me think twice about the idea and possibly 
making an exception to the rule. I think it'll improve the look of PHP 
scripts. Also I think people calling methods using 
call_user_method([$obj, method]); will find it sexier than the array() 
syntax.
I guess I think it'd be interesting to see what other's think. Also, 
another point to check is if list() can also be converted into [] 
because having a hybrid wouldn't be too nice.

Andi

At 12:33 AM 11/5/2003 +0100, Christian Schneider wrote:

I propose to add an alternative (backward compatible) short array 
creation syntax:
$a = [ 1, 2, 3 ]; and $a = [ 'a' = 42, 'b' = foo ];

It can also be used in function calls:
img(['src' = logo.gif, 'alt' = Logo]);
Reason behind this change: Arrays are used a lot and should therefore 
have as little syntactic overhead as possible. And I think the short 
syntax is also easier to read and write.

A patch for the parser is trivial and is attached for Zend2.

Note: I checked the newsgroup archive but couldn't find a discussion 
about this. After not hearing back about my proposed enhancement to 
debug_backtrace() and the dangling comma for function call parameters 
being rejected I wonder if I'm using the right mailing list for this :-)

- Chris

Index: Zend/zend_language_parser.y
===
RCS file: /repository/ZendEngine2/zend_language_parser.y,v
retrieving revision 1.127
diff -u -r1.127 zend_language_parser.y
--- Zend/zend_language_parser.y 19 Oct 2003 08:38:48 -  1.127
+++ Zend/zend_language_parser.y 4 Nov 2003 23:32:12 -
@@ -581,6 +581,7 @@
|   '@' { zend_do_begin_silence($1 TSRMLS_CC); } expr { 
zend_do_end_silence($1 TSRMLS_CC); $$ = $3; }
|   scalar  { $$ = $1; }
|   T_ARRAY '(' array_pair_list ')' { $$ = $3; }
+   |   '[' array_pair_list ']' { $$ = $2; }
|   '`' encaps_list '`' { 
zend_do_shell_exec($$, $2 TSRMLS_CC); }
|   T_PRINT expr  { zend_do_print($$, $2 TSRMLS_CC); }
 ;

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Magnus Määttä
On Wed, 5 Nov 2003 08:06:53 -0500
Ilia Alshanetsky [EMAIL PROTECTED] wrote:

 I do not like the new syntax at all. If anything it seems rather unnatural and  
 what do you save, typing of 5 characters that makes it clear that this is an 
 array to even the most novice of users? It certainly not going to make the 
 code any faster and if anything will only add confusion.
 
 Firm -1.

I totally agree with Ilia.
And it doesn't take more than 0.4 seconds to type array anyway.


array(My 0.2c,  = Magnus);

-- 
What does it mean if there is no fortune for you?

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Derick Rethans
On Wed, 5 Nov 2003, Ilia Alshanetsky wrote:

 I do not like the new syntax at all. If anything it seems rather unnatural and 
 what do you save, typing of 5 characters that makes it clear that this is an 
 array to even the most novice of users? It certainly not going to make the 
 code any faster and if anything will only add confusion.
 
 Firm -1.

Right, one point of confusion is using [] both for initialising array 
and indexing them. I'm -1 on this too, array() and range() wosk fine.

Derick

-- 
Interpreting what the GPL actually means is a job best left to those
that read the future by examining animal entrails.
-
 Derick Rethans http://derickrethans.nl/ 
 International PHP Magazine  http://php-mag.net/
-

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Christian Schneider
Ok, I tried to just listen to what people are saying but this comment 
went too far ;-)

Antony Dovgal wrote:
No, it looks like someone trying to turn PHP into Perl (or Python).
I'm just trying to improve PHP. And I write _a lot_ of PHP code, so I 
have some idea about where the syntax could be improved IMHO.

Personally I would prefer not to import Perl-style  Python-style syntax to PHP.
PHP is a mix of C, Perl and other styles anyway, why deny it? It's 
strength is that it's a pragmatic and simple language but that doesn't 
mean that nothing should be changed ever.

These things already work well(yes, you can think, that array()  range()
 are ugly, but they are already used in tonns of projects) and I can't see

I don't want to break existing programs. And I don't care about range() 
(or even list() too much for that matter), I just recognize the fact the 
I'm using a lot of array() and it is both unnecessarily hard to write 
_and_ read.
Saying that array() works well and [] is incomprehensible just does not 
match my experience. Both for myself (some years of programming 
experience) and for newbies. I saw no difference teaching people to 
initialize an array with array() or []. Someone new to programming has 
to memorize that he has to write $a = array() (and not $a = new array() 
for example) anyway, $a = [] would be just as easy IMHO.

 any reasons to change such fundamental things just because version number
 changes from 4 to 5.
So why was the whole private/public/static/throw/catch thing introduced? 
 Following your logic people who want this should use Java. I'm much 
more worried about code getting unreadable because of these extensions 
actually. It turned PHP into a much more complex language but since it 
is all optional I don't mind. But to deny some simple (and backward 
compatible) syntactic sugar to people who just want an easy to use 
language seems missing the point to me.

If you really like this syntax - use Perl or Python, or whatever you want,
 but I really can't understand why PHP should allow you to use this 
syntax too.

I like some of the Python syntax. But some of it is cumbersome. Same 
with PHP. But I think PHP is closer to what I want so what's wrong with 
trying to improve it where it's possible (and easily done)? I used Perl 
4 back in the early days but I was horrified by some stuff they added 
with Perl 5. Perl 6 is actually making some things better again (but no, 
I'm not going to use it when it comes out in 2010).

[ 'my_cents' = .02 ],
- Chris
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Nicolas Toper
Hi,

I'm new to the list. I've come trough your post and as a PHP end user I
can say that array are easy to use but they could be a lot easier...

You don't want Perl features? Please don't delete the for each operator :=)

-Message d'origine-
De : Christian Schneider [mailto:[EMAIL PROTECTED]
Envoye : mercredi 5 novembre 2003 16:35
A : Antony Dovgal
Cc : [EMAIL PROTECTED]
Objet : Re: [PHP-DEV] Proposal: Array syntax


Ok, I tried to just listen to what people are saying but this comment
went too far ;-)

Antony Dovgal wrote:
 No, it looks like someone trying to turn PHP into Perl (or Python).

I'm just trying to improve PHP. And I write _a lot_ of PHP code, so I
have some idea about where the syntax could be improved IMHO.

 Personally I would prefer not to import Perl-style  Python-style syntax
to PHP.

PHP is a mix of C, Perl and other styles anyway, why deny it? It's
strength is that it's a pragmatic and simple language but that doesn't
mean that nothing should be changed ever.

 These things already work well(yes, you can think, that array()  range()
  are ugly, but they are already used in tonns of projects) and I can't see

I don't want to break existing programs. And I don't care about range()
(or even list() too much for that matter), I just recognize the fact the
I'm using a lot of array() and it is both unnecessarily hard to write
_and_ read.
Saying that array() works well and [] is incomprehensible just does not
match my experience. Both for myself (some years of programming
experience) and for newbies. I saw no difference teaching people to
initialize an array with array() or []. Someone new to programming has
to memorize that he has to write $a = array() (and not $a = new array()
for example) anyway, $a = [] would be just as easy IMHO.

  any reasons to change such fundamental things just because version number
  changes from 4 to 5.

So why was the whole private/public/static/throw/catch thing introduced?
  Following your logic people who want this should use Java. I'm much
more worried about code getting unreadable because of these extensions
actually. It turned PHP into a much more complex language but since it
is all optional I don't mind. But to deny some simple (and backward
compatible) syntactic sugar to people who just want an easy to use
language seems missing the point to me.

 If you really like this syntax - use Perl or Python, or whatever you want,
  but I really can't understand why PHP should allow you to use this
syntax too.

I like some of the Python syntax. But some of it is cumbersome. Same
with PHP. But I think PHP is closer to what I want so what's wrong with
trying to improve it where it's possible (and easily done)? I used Perl
4 back in the early days but I was horrified by some stuff they added
with Perl 5. Perl 6 is actually making some things better again (but no,
I'm not going to use it when it comes out in 2010).

[ 'my_cents' = .02 ],
- Chris

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Ilia Alshanetsky
On November 5, 2003 10:34 am, Christian Schneider wrote:
 PHP is a mix of C, Perl and other styles anyway, why deny it? It's
 strength is that it's a pragmatic and simple language but that doesn't
 mean that nothing should be changed ever.

PHP strength (IMHO) is it's simple and clear syntax, which allows people who 
come from background in other programming languages can quickly recognize and 
get used to. Creating confusing alternate syntaxes will bring us ever closer 
to Perl 6 where there are dozens of way to do the same thing. The end results 
in a confusing and hard to read/write language that all but the most 
dedicated of users refuse to use.

 I don't want to break existing programs. And I don't care about range()
 (or even list() too much for that matter), I just recognize the fact the
 I'm using a lot of array() and it is both unnecessarily hard to write
 _and_ read.

That's bull, 5 characters is hard to write? If anything those 5 characters 
make it absolutely clear to ANYONE that the data is an array and not an 
object or a string or some other type. When I first saw the syntax is took me 
a few seconds to realize what it does and the problem would only be 
compounded when the code is found within an pre-existing complex script.

Ilia

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Antony Dovgal
On Wed, 05 Nov 2003 16:34:52 +0100
Christian Schneider [EMAIL PROTECTED] wrote:

 I'm just trying to improve PHP. And I write _a lot_ of PHP code, so I 
 have some idea about where the syntax could be improved IMHO.

changing the syntax is not the best way imho.
 
 PHP is a mix of C, Perl and other styles anyway, why deny it? It's 
 strength is that it's a pragmatic and simple language but that doesn't 
 mean that nothing should be changed ever.

because PHP is PHP.
in C you can use assembler code insertions, but it doesn't mean, that PHP's strength 
should be powered by allowing assembler insertions.
if in Python you can create new array, using $a = [];, it doesn't mean, that PHP 
should be able to do it in the same way.

 I don't want to break existing programs. And I don't care about range() 
 (or even list() too much for that matter), I just recognize the fact the 
 I'm using a lot of array() and it is both unnecessarily hard to write 
 _and_ read.
 Saying that array() works well and [] is incomprehensible just does not 
 match my experience. Both for myself (some years of programming 
 experience) and for newbies. I saw no difference teaching people to 
 initialize an array with array() or []. Someone new to programming has 
 to memorize that he has to write $a = array() (and not $a = new array() 
 for example) anyway, $a = [] would be just as easy IMHO.

this is very confusing way to improve PHP.
you will type 2 symbols instead of 7, but you forget, that you use almost same syntax 
for indexing arrays.
do you agree, that $a[] = ''; and $a = []; look almost similar for newbies?


   any reasons to change such fundamental things just because version number
   changes from 4 to 5.
 
 So why was the whole private/public/static/throw/catch thing introduced? 
   Following your logic people who want this should use Java. I'm much 
 more worried about code getting unreadable because of these extensions 
 actually. It turned PHP into a much more complex language but since it 
 is all optional I don't mind. But to deny some simple (and backward 
 compatible) syntactic sugar to people who just want an easy to use 
 language seems missing the point to me.

you're misrepresenting my words. 
PHP didn't have some kind of private/public/static/throw/catch before.
and you're trying to invent new kind of wheel, 'cause you think common model of wheel 
is ugly.

 I like some of the Python syntax. But some of it is cumbersome. Same 
 with PHP. But I think PHP is closer to what I want so what's wrong with 
 trying to improve it where it's possible (and easily done)?

agree, and you can easily make PHP code not readable with such improvements.
again, I can't understand why PHP should have another way of creating new arrays.
there are so many things you can improve in PHP - why did you choose to change the 
syntax?

so, I'm still strongly against such improvements.

---
WBR,
Antony Dovgal aka tony2001
[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Rasmus Lerdorf
On Wed, 5 Nov 2003, Ilia Alshanetsky wrote:
 On November 5, 2003 10:34 am, Christian Schneider wrote:
  PHP is a mix of C, Perl and other styles anyway, why deny it? It's
  strength is that it's a pragmatic and simple language but that doesn't
  mean that nothing should be changed ever.
 
 PHP strength (IMHO) is it's simple and clear syntax, which allows people who 
 come from background in other programming languages can quickly recognize and 
 get used to. Creating confusing alternate syntaxes will bring us ever closer 
 to Perl 6 where there are dozens of way to do the same thing. The end results 
 in a confusing and hard to read/write language that all but the most 
 dedicated of users refuse to use.

Well, like I said before, I am not sure this is a clear case of that.  I'm 
probably the biggest defender around of the no-magic rule, but [] does 
imply something array-related to most people, so I think the magic part is 
much smaller than in other proposals we have seen.

 That's bull, 5 characters is hard to write? If anything those 5 characters 
 make it absolutely clear to ANYONE that the data is an array and not an 
 object or a string or some other type. When I first saw the syntax is took me 
 a few seconds to realize what it does and the problem would only be 
 compounded when the code is found within an pre-existing complex script.

I do agree that [1,2,3] is not easier to read than array(1,2,3), but I 
don't think there is a huge difference between the two.  I guess we could 
sample a few newbie users to see what they think $a = [1,2,3]; would do.
Of course, then people are going to try to do $a = $b[1,2,3]; and then we 
are all messed up.

-Rasmus

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Christian Schneider
Antony Dovgal wrote:
do you agree, that $a[] = ''; and $a = []; look almost similar for newbies?
And they both deal with arrays. That's not confusing to me.
Why have $a[] = ''; then in the first place? You already have 
array_push($a, ''). Or do you seriously think $a[] = ''; shouldn't be there?

PHP didn't have some kind of private/public/static/throw/catch before.
Not true, you could do the same thing manually. Very ugly but possible. 
But that's academic.

and you're trying to invent new kind of wheel, 'cause you think common model of wheel is ugly.
I'm trying to remove bumps from existing wheels because I thinks the car 
is almost perfect. That's the main problem: You think it needs whole new 
constructs but the existing ones are perfect whereas I think some of the 
existing constructs could use some polishing but have no need for 'big' 
changes. And I accept that some people want things like throw, catch or 
final but you don't accept that having an elegant syntax for writing 
simple code is important to me.

again, I can't understand why PHP should have another way of creating new arrays.
Again, cecause it's nicer to use (read and write) IMHO. Especially for 
nested arrays and arrays in function calls.

there are so many things you can improve in PHP - why did you choose to change the syntax?
Because I don't think PHP _needs_ major changes.
I was trying to convince people on the phpdev list that PHP4 should use 
references instead of copying objects back then when it was designed but 
was rejected. Now this is finally changed in PHP5 which is great. This 
was basically my last major complaint about the object model and 
language constructs and that's why I'm trying to work on the details.

- Chris

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Ilia Alshanetsky
On November 5, 2003 11:21 am, you wrote:
 Well, like I said before, I am not sure this is a clear case of that.  I'm
 probably the biggest defender around of the no-magic rule, but [] does
 imply something array-related to most people, so I think the magic part is
 much smaller than in other proposals we have seen.

Right now [] could either be an array element or an offset. Now it can either 
be an array element or a string offset or an attempt to create a new array. 
Individually it may be fine, but I am certain we'll end up with bug reports 
of people trying to do $a = $b[1,2,3]; (copied from your resonse ;) ) and 
similar. Of course someone would then want to do $a[1,2,3] = [3,4,5]; and 
we're happily on our road to obfuscation.

I mean c'mon, is 5 characters that much of a problem and is absolute code 
clarity not worth those 5 characters? Character efficiency is done in Perl, 
where you can do things like ~= and @_, but that makes Perl code naturally 
obfuscated and I do not think that's a good way to go.

Ilia

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Andi Gutmans
At 11:48 AM 11/5/2003 -0500, Ilia Alshanetsky wrote:
On November 5, 2003 11:21 am, you wrote:
 Well, like I said before, I am not sure this is a clear case of that.  I'm
 probably the biggest defender around of the no-magic rule, but [] does
 imply something array-related to most people, so I think the magic part is
 much smaller than in other proposals we have seen.
Right now [] could either be an array element or an offset. Now it can either
be an array element or a string offset or an attempt to create a new array.
Individually it may be fine, but I am certain we'll end up with bug reports
of people trying to do $a = $b[1,2,3]; (copied from your resonse ;) ) and
similar. Of course someone would then want to do $a[1,2,3] = [3,4,5]; and
we're happily on our road to obfuscation.
I mean c'mon, is 5 characters that much of a problem and is absolute code
clarity not worth those 5 characters? Character efficiency is done in Perl,
where you can do things like ~= and @_, but that makes Perl code naturally
obfuscated and I do not think that's a good way to go.
I don't believe in saving characters. You probably know that I tend to 
prefer looong meaningful names and not have all sorts of magic. I think 
in this case, it's not a matter of saving the typing as it looks much 
better and IMO is more intuitive.
Anyway, it's no biggy and if most people here think it shouldn't be added 
then that's fine with me.

Andi

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Jani Taskinen
On Wed, 5 Nov 2003, Ilia Alshanetsky wrote:

I do not like the new syntax at all. If anything it seems rather unnatural and 
what do you save, typing of 5 characters that makes it clear that this is an 
array to even the most novice of users? It certainly not going to make the 
code any faster and if anything will only add confusion.

Firm -1.

There's enough magic already..I could say +1 if magic_quotes_* 
is removed and everything is made case-sensitive first. :)

--Jani


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Ford, Mike [LSS]
On 05 November 2003 15:57, Ilia Alshanetsky contributed these pearls of
wisdom:

 On November 5, 2003 10:34 am, Christian Schneider wrote:
 PHP is a mix of C, Perl and other styles anyway, why deny it?
 It's strength is that it's a pragmatic and simple language
 but that doesn't mean that nothing should be changed ever.
 
 PHP strength (IMHO) is it's simple and clear syntax, which
 allows people who
 come from background in other programming languages can
 quickly recognize and
 get used to. Creating confusing alternate syntaxes will bring
 us ever closer
 to Perl 6 where there are dozens of way to do the same thing.
 The end results
 in a confusing and hard to read/write language that all but
 the most dedicated of users refuse to use.

Yes, I agree with this, but I also think that a modicum of alternatives in a
few strategically chosen places also makes a language easier to use for
people coming from different backgrounds and with different style prejudices
-- or even just with differently-built brains!  A prime example of this is
the alternative structure syntax -- as a confirmed and long-time hater of
the curly-brackets-for-everything style (as a result of many years of using
it in B, c, JavaScript and others), I was overjoyed to discover the
alternative :-syntax in PHP and use it exclusively in all my scripts.
Contrariwise, there are some features in (and not in!) PHP that I think are
pretty silly, but some of its prime maintainers defend to the death -- well,
that's their opinion and I would defend to the death their right to have it,
whilst nevertheless continuing to disagree with them.

 I don't want to break existing programs. And I don't care
 about range() (or even list() too much for that matter), I
 just recognize the fact the I'm using a lot of array() and it
 is both unnecessarily hard to write _and_ read.
 
 That's bull, 5 characters is hard to write? If anything those
 5 characters make it absolutely clear to ANYONE that the data
 is an array 
 and not an
 object or a string or some other type. When I first saw the
 syntax is took me
 a few seconds to realize what it does and the problem would
 only be compounded when the code is found within an
 pre-existing 
 complex script.

Well, my view on that is the exact contrary -- I find the 5 letters in
question and their associated parentheses easy to lose in the surrounding
and very similar code, whereas the [] syntax both stands out much better
against surrounding noise and is, for me, more intuitive.  I think there's
room for both -- I and all the other +1s would no doubt enthusiastically
switch over wholesale to [], whilst you and the other -1s would stick with
array().  I would have no problem with that, and to me it would be an
advantage of the language that it supports such choice.

Cheers!

Mike

-- 
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Marco Tabini
Rasmus Lerdorf wrote:
On Wed, 5 Nov 2003, Ilia Alshanetsky wrote:

On November 5, 2003 10:34 am, Christian Schneider wrote:

PHP is a mix of C, Perl and other styles anyway, why deny it? It's
strength is that it's a pragmatic and simple language but that doesn't
mean that nothing should be changed ever.
PHP strength (IMHO) is it's simple and clear syntax, which allows people who 
come from background in other programming languages can quickly recognize and 
get used to. Creating confusing alternate syntaxes will bring us ever closer 
to Perl 6 where there are dozens of way to do the same thing. The end results 
in a confusing and hard to read/write language that all but the most 
dedicated of users refuse to use.


Well, like I said before, I am not sure this is a clear case of that.  I'm 
probably the biggest defender around of the no-magic rule, but [] does 
imply something array-related to most people, so I think the magic part is 
much smaller than in other proposals we have seen.

But isn't there a big difference between an assignment and a reference?
I, for one, think that language constructs should be as univocal as 
possible in order to minimize confusion, lest we end up having to read 
something like:

$a = [[1,2,3],[1=[1,3,2,2], a=[[1,2,3,4],4,[1,2]]];

I don't know about you, but I can't even begin to count the brackets in 
there... :-)

Cheers,

Marco

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Christian Schneider
Andi Gutmans wrote:
 I don't believe in saving characters.
Agreed, it's not about saving characters (only).

Anyway, it's no biggy and if most people here think it shouldn't be 
added then that's fine with me.
Ok, a quick head count gave 9 people pro, 6 people con and 3 people I 
couldn't figure out if they are pro or con (-:C

- Chris

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread George Schlossnagle
On Nov 5, 2003, at 11:52 AM, Marco Tabini wrote:
But isn't there a big difference between an assignment and a reference?
I, for one, think that language constructs should be as univocal as 
possible in order to minimize confusion, lest we end up having to read 
something like:

$a = [[1,2,3],[1=[1,3,2,2], a=[[1,2,3,4],4,[1,2]]];

I don't know about you, but I can't even begin to count the brackets 
in there... :-)
is that any less clear than

$a = array(array(1,2,3), array(1 = array(1,3,2,2), array(a = 
array(array(1,2,3,4), 4, array(1,2)));

Both examples can be made crystal clear with appropriate whitespace.

George

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Jani Taskinen
On Wed, 5 Nov 2003, Christian Schneider wrote:

Andi Gutmans wrote:
  I don't believe in saving characters.

Agreed, it's not about saving characters (only).

 Anyway, it's no biggy and if most people here think it shouldn't be 
 added then that's fine with me.

Ok, a quick head count gave 9 people pro, 6 people con and 3 people I 
couldn't figure out if they are pro or con (-:C

I think Andi meant the PHP developers, not some random user out there..
(Last time I checked, OS isn't synonym for democrazy. :)

--Jani


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Christian Schneider
Marco Tabini wrote:
$a = [[1,2,3],[1=[1,3,2,2], a=[[1,2,3,4],4,[1,2]]];
$a = array(array(1,2,3),array(1=array(1,3,2,2), 
a=array(array(1,2,3,4),4,array(1,2)));

What was your point again? ;-)

- Chris

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Marco Tabini
George Schlossnagle wrote:
On Nov 5, 2003, at 11:52 AM, Marco Tabini wrote:

But isn't there a big difference between an assignment and a reference?
I, for one, think that language constructs should be as univocal as 
possible in order to minimize confusion, lest we end up having to read 
something like:

$a = [[1,2,3],[1=[1,3,2,2], a=[[1,2,3,4],4,[1,2]]];

I don't know about you, but I can't even begin to count the brackets 
in there... :-)


is that any less clear than

$a = array(array(1,2,3), array(1 = array(1,3,2,2), array(a = 
array(array(1,2,3,4), 4, array(1,2)));

Both examples can be made crystal clear with appropriate whitespace.
Except that the word array provides a nice break *and* it does not 
create confusion in the use of a language construct (see my previous msgs).

Cheers,

Marco

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Marco Tabini
Christian Schneider wrote:
Marco Tabini wrote:

$a = [[1,2,3],[1=[1,3,2,2], a=[[1,2,3,4],4,[1,2]]];


$a = array(array(1,2,3),array(1=array(1,3,2,2), 
a=array(array(1,2,3,4),4,array(1,2)));

Besides my previous points, something even more abominable:

$a = [1,2,$b[11]];

Is that confusing enough for you? ;-)

Mt.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Ford, Mike [LSS]
On 05 November 2003 16:48, Ilia Alshanetsky contributed these pearls of
wisdom:

 I mean c'mon, is 5 characters that much of a problem and is
 absolute code clarity not worth those 5 characters? Character
 efficiency is done in Perl, where you can do things like ~=
 and @_, but that makes Perl code naturally obfuscated and I do
 not think that's a good way to go. 

I don't think the number of characters is the main issue here -- it's about
having a *nicer* set of characters.  Personally, I'd be still be in favour
(although not quite as much) if the proposed syntax were [[[1,2,3]]] -- for
me, it's about having a syntax that shouts *ARRAY* rather than whispers it.
(Although the reduction in characters is handy -- particularly in a
construct like ['foo' = ['bar'='on', 'baz'=[2,3,5,7]],
'bedrock'=['rubble'=['barney', 'betty'], 'flintstone'=['fred',
'wilma']]].)

Cheers!

Mike

-- 
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Ford, Mike [LSS]
On 05 November 2003 17:06, Marco Tabini contributed these pearls of wisdom:

 Christian Schneider wrote:
 Marco Tabini wrote:
 
 $a = [[1,2,3],[1=[1,3,2,2], a=[[1,2,3,4],4,[1,2]]];
 
 
 $a = array(array(1,2,3),array(1=array(1,3,2,2),
 a=array(array(1,2,3,4),4,array(1,2)));
 
 
 Besides my previous points, something even more abominable:
 
 $a = [1,2,$b[11]];
 
 Is that confusing enough for you? ;-)

What's confusing about it?

Cheers!

Mike

-- 
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Ford, Mike [LSS]
On 05 November 2003 16:52, Marco Tabini contributed these pearls of wisdom:

 
 $a = [[1,2,3],[1=[1,3,2,2], a=[[1,2,3,4],4,[1,2]]];
 
 I don't know about you, but I can't even begin to count the
 brackets in there... :-)

At quick glance says it looks unbalanced.  A count shows why: 7 [s and 6 ]s
;)

I couldn't begin to suggest whether you left out a ] or have one too many [,
or where...!!

Cheers!

Mike

-- 
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Marco Tabini
Ford, Mike [LSS] wrote:
On 05 November 2003 17:06, Marco Tabini contributed these pearls of wisdom:


Christian Schneider wrote:

Marco Tabini wrote:


$a = [[1,2,3],[1=[1,3,2,2], a=[[1,2,3,4],4,[1,2]]];


$a = array(array(1,2,3),array(1=array(1,3,2,2),
a=array(array(1,2,3,4),4,array(1,2)));
Besides my previous points, something even more abominable:

$a = [1,2,$b[11]];

Is that confusing enough for you? ;-)


What's confusing about it?

The fact that $b[11] references an item of an array, while [1,2,$b[11]] 
assigns values to the array $a. The fact that you (and, probably, most 
of us) can't tell right off the bat is a clear sign that this is a bad 
idea, because it's ambiguous and confusing.

The same line using the current syntax, btw, would have looked like this:

$a = array (1,3,$b[11]);

As you can see the ambiguity is gone--square brackets are used for one 
purpose and nothing else.

Cheers,

Marco

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Ilia Alshanetsky
On November 5, 2003 12:01 pm, Ford, Mike [LSS] wrote:
 I don't think the number of characters is the main issue here -- it's about
 having a *nicer* set of characters.  Personally, I'd be still be in favour
 (although not quite as much) if the proposed syntax were [[[1,2,3]]] -- for
 me, it's about having a syntax that shouts *ARRAY* rather than whispers it.
 (Although the reduction in characters is handy -- particularly in a
 construct like ['foo' = ['bar'='on', 'baz'=[2,3,5,7]],
 'bedrock'=['rubble'=['barney', 'betty'], 'flintstone'=['fred',
 'wilma']]].)

Sure, now support one of your string array keys/values contains a [ or ] 
character. That would wreak havoc with the readability of the code.

Having 2 separate syntaxes would mean that some devs would use one format and 
the other another. And eventually you'll end up with the same code written in 
2 separate ways within the same script/application because 1 part (older?) 
was written in 1 way and the other (newer) written in another. This makes the 
entire application more difficult to understand and since many people learn 
through modifying scripts you'll create more barriers to entry for new users.

A few more examples how this will cause problems:

$a[1,2,3,4][] = [5,6,7,8][2];

Ilia

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Steph
OK .. I'm a wobbler.

I think it would be cool to have the cleaner alternative syntax; I think I'd
use it *in some situations and not others*, and I think that that in itself
would make my code virtually unmaintainable by anyone else.

As Andi originally said, having more than one way to do things isn't always
a good thing.

Add me to the -1 list.  Even tho' it's a cool idea.

- Steph


 -Original Message-
 From: Christian Schneider [mailto:[EMAIL PROTECTED]
 Sent: 04 November 2003 23:33
 To: [EMAIL PROTECTED]
 Subject: [PHP-DEV] Proposal: Array syntax


 I propose to add an alternative (backward compatible) short array
 creation syntax:
 $a = [ 1, 2, 3 ]; and $a = [ 'a' = 42, 'b' = foo ];

 It can also be used in function calls:
 img(['src' = logo.gif, 'alt' = Logo]);

 Reason behind this change: Arrays are used a lot and should therefore
 have as little syntactic overhead as possible. And I think the short
 syntax is also easier to read and write.

 A patch for the parser is trivial and is attached for Zend2.

 Note: I checked the newsgroup archive but couldn't find a discussion
 about this. After not hearing back about my proposed enhancement to
 debug_backtrace() and the dangling comma for function call parameters
 being rejected I wonder if I'm using the right mailing list for this :-)

 - Chris


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Andi Gutmans
At 11:58 AM 11/5/2003 -0500, George Schlossnagle wrote:

On Nov 5, 2003, at 11:52 AM, Marco Tabini wrote:
But isn't there a big difference between an assignment and a reference?
I, for one, think that language constructs should be as univocal as 
possible in order to minimize confusion, lest we end up having to read 
something like:

$a = [[1,2,3],[1=[1,3,2,2], a=[[1,2,3,4],4,[1,2]]];

I don't know about you, but I can't even begin to count the brackets in 
there... :-)
is that any less clear than

$a = array(array(1,2,3), array(1 = array(1,3,2,2), array(a = 
array(array(1,2,3,4), 4, array(1,2)));

Both examples can be made crystal clear with appropriate whitespace.
I agree with that.

Andi

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Romans Malinovskis

Think backwards.. Will you be able to convince
any perl/python/javascript developer to use
array(), list(), range() structs?

r

 $a = [1,2,$b[11]];

 Is that confusing enough for you? ;-)


 Mt.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Marco Tabini
Romans Malinovskis wrote:
Think backwards.. Will you be able to convince
any perl/python/javascript developer to use
array(), list(), range() structs?
I really don't think this needs to be a concern. You can't be everything 
to all people.

Mt.

r


$a = [1,2,$b[11]];

Is that confusing enough for you? ;-)

Mt.


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Derick Rethans
On Wed, 5 Nov 2003, Christian Schneider wrote:

 Andi Gutmans wrote:
   I don't believe in saving characters.
 
 Agreed, it's not about saving characters (only).
 
  Anyway, it's no biggy and if most people here think it shouldn't be 
  added then that's fine with me.
 
 Ok, a quick head count gave 9 people pro, 6 people con and 3 people I 
 couldn't figure out if they are pro or con (-:C

Do you think your vote counts? :)

Derick

-- 
Interpreting what the GPL actually means is a job best left to those
that read the future by examining animal entrails.
-
 Derick Rethans http://derickrethans.nl/ 
 International PHP Magazine  http://php-mag.net/
-

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread George Schlossnagle
On Nov 5, 2003, at 12:33 PM, Derick Rethans wrote:

On Wed, 5 Nov 2003, Christian Schneider wrote:

Andi Gutmans wrote:
I don't believe in saving characters.
Agreed, it's not about saving characters (only).

Anyway, it's no biggy and if most people here think it shouldn't be
added then that's fine with me.
Ok, a quick head count gave 9 people pro, 6 people con and 3 people I
couldn't figure out if they are pro or con (-:C
Do you think your vote counts? :)
Not that mine necessarily does, but I'm -1 for alternative syntaxes.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Andrey Hristov
On Wed, 5 Nov 2003, Christian Schneider wrote:


Andi Gutmans wrote:
  I don't believe in saving characters.
Agreed, it's not about saving characters (only).

 

 Anyway, it's no biggy and if most people here think it shouldn't be 
 added then that's fine with me.
   

Ok, a quick head count gave 9 people pro, 6 people con and 3 people I 
couldn't figure out if they are pro or con (-:C
 

The devs are mostly at the conference now. I think it is easy to discuss.
I won't be surprised if cons after that are more than pros.
One more thing, I think that not PHP but another scripting language is
famous with There is more than one way to do it!.
Andrey

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Rasmus Lerdorf
On Wed, 5 Nov 2003, Christian Schneider wrote:

 Andi Gutmans wrote:
   I don't believe in saving characters.
 
 Agreed, it's not about saving characters (only).
 
  Anyway, it's no biggy and if most people here think it shouldn't be 
  added then that's fine with me.
 
 Ok, a quick head count gave 9 people pro, 6 people con and 3 people I 
 couldn't figure out if they are pro or con (-:C

In case it wasn't clear, I am a -0 on this.  I don't mind the syntax, but 
having two different syntaxes is the big problem here.

-Rasmus

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Edin Kadribasic
On Wednesday, Nov 5, 2003, at 17:48 Europe/Copenhagen, Andi Gutmans 
wrote:

Anyway, it's no biggy and if most people here think it shouldn't be 
added then that's fine with me.
I like the new syntax proposal, especially when passing arrays as 
function parameters.

+1 here.

Edin

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Romans Malinovskis
 The devs are mostly at the conference now. I think it is easy to discuss.
 I won't be surprised if cons after that are more than pros.

I think end-user / newbie votes should be rather considered than dev's since
they are ones who will be learning and getting used to this syntax. So why
don't place a pool on some php developer website? That would be more correct
to php real users.

r

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Jaap van Ganswijk
At 2003-11-05 09:59 +0100, Michael Walter wrote:
Very cool.

How about supporting .. syntax, btw. as in [1..3] or [a..z]? Might no be the 
worth, just thinking out loud ;)

I'm also in favor of a shorter notation for array() and list().

In fact this also helps to ease the problem I have
with 'foreach ($A as $I=$d)', because it would
then be possible to write: while ([$i,$d]=each($A)).
It's still not as short as I'd like it to be:
'while ($i=$d in $A)', but it's already a lot
better.

I'd also like to see ranges supported and propose
to add notations for inclusive and non-inclusive
ranges as:
1..3 inclusive at both ends so equal to 1,2,3
1.3 non inclusive at the end so equal to 1,2
1.3 non inclusive at the beginning so equal to 2,3
13 non inclusive at both ends so equal to 2

Of course generally only the first two variations
are being used.

(Please note that this syntax conflicts slightly
with the syntax of floating point numbers and
compares. Perhaps it's solvable by scanning '..',
'.', '.' and '' as tokens first and not
allowing ranges with floating point numbers
anyway.)

By the way, Python has three 'group' notations:
[] for a list
{} for a dictionary
() for a tuple

Very confusing (and one of the reasons I prefer PHP
over Python ;-), and I agree with Rasmus that at least
here the symbols no longer make clear what is being
meant, but I think that just [] for the values in an
array is very intuitive because the same symbols are
being used to add the index of an array. (But {}
from the set notion in mathematics would be fine too,
I think).

By the way, don't forget to allow a comma at the end
of a list: 1,2,3,

This especially makes sense when the elements are
listed each on a seperate line:
1,
2,
3,

Greetings,
Jaap


Christian Schneider wrote:
I propose to add an alternative (backward compatible) short array creation syntax:
$a = [ 1, 2, 3 ]; and $a = [ 'a' = 42, 'b' = foo ];
It can also be used in function calls:
img(['src' = logo.gif, 'alt' = Logo]);
Reason behind this change: Arrays are used a lot and should therefore have as little 
syntactic overhead as possible. And I think the short syntax is also easier to read 
and write.
A patch for the parser is trivial and is attached for Zend2.
Note: I checked the newsgroup archive but couldn't find a discussion about this. 
After not hearing back about my proposed enhancement to debug_backtrace() and the 
dangling comma for function call parameters being rejected I wonder if I'm using the 
right mailing list for this :-)
- Chris


Index: Zend/zend_language_parser.y
===
RCS file: /repository/ZendEngine2/zend_language_parser.y,v
retrieving revision 1.127
diff -u -r1.127 zend_language_parser.y
--- Zend/zend_language_parser.y 19 Oct 2003 08:38:48 -  1.127
+++ Zend/zend_language_parser.y 4 Nov 2003 23:32:12 -
@@ -581,6 +581,7 @@
|   '@' { zend_do_begin_silence($1 TSRMLS_CC); } expr { 
 zend_do_end_silence($1 TSRMLS_CC); $$ = $3; }
|   scalar  { $$ = $1; }
|   T_ARRAY '(' array_pair_list ')' { $$ = $3; }
+   |   '[' array_pair_list ']' { $$ = $2; }
|   '`' encaps_list '`' { zend_do_shell_exec($$, $2 
 TSRMLS_CC); }
|   T_PRINT expr  { zend_do_print($$, $2 TSRMLS_CC); }
 ;

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Cesare D'Amico
Alle 18:48, mercoledì 5 novembre 2003, Romans Malinovskis ha scritto:
  The devs are mostly at the conference now. I think it is easy to
  discuss. I won't be surprised if cons after that are more than
  pros.

 I think end-user / newbie votes should be rather considered than
 dev's since they are ones who will be learning and getting used to
 this syntax. So why don't place a pool on some php developer website?
 That would be more correct to php real users.

I don't think so. Dev's have an understanding of php as a whole that 
most people haven't, so they are more clever in judging new features.

Moreover, i agree with Steph:

 I think it would be cool to have the cleaner alternative syntax; I
 think I'd use it *in some situations and not others*, and I think that
 that in itself would make my code virtually unmaintainable by anyone
 else.

This is really a good point to me.

Ciao
 ce
-- 
Cesare D'Amico - http://www.phpday.it
E` un'emergenza!!! Dovrei fare questo-e-questaltro ma non 
posso perche' la mia testa e` piena di segatura e criceti!!!
 -- un utente [ http://www.soft-land.org/storie/ ]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Andrey Hristov
Jaap van Ganswijk wrote:

At 2003-11-05 09:59 +0100, Michael Walter wrote:
 

Very cool.

How about supporting .. syntax, btw. as in [1..3] or [a..z]? Might no be the worth, just thinking out loud ;)
   

I'm also in favor of a shorter notation for array() and list().

In fact this also helps to ease the problem I have
with 'foreach ($A as $I=$d)', because it would
then be possible to write: while ([$i,$d]=each($A)).
 

Do you know that while(list(..,..) = each($ar))
is kinda deprecated. You should consider using
foreach() which is clearer and the fastest way to
traverse an array. while() + each() + list() is the
old way (evermore, you have not to forget to reset()
your array before the traversal - foreach() does not
need this step).
Andrey

It's still not as short as I'd like it to be:
'while ($i=$d in $A)', but it's already a lot
better.
I'd also like to see ranges supported and propose
to add notations for inclusive and non-inclusive
ranges as:
1..3 inclusive at both ends so equal to 1,2,3
 

1.3 non inclusive at the end so equal to 1,2
1.3 non inclusive at the beginning so equal to 2,3
13 non inclusive at both ends so equal to 2
 

Use the range() function. PHP is more close to C than to
Pascal in my opinion. The language should be simple the
standard library should be rich (IMO).
Andrey

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Marco Tabini
Michael Walter wrote:
$a = [1,2,$b[11]];

Is that confusing enough for you? ;-)




What's confusing about it?

The fact that $b[11] references an item of an array, while 
[1,2,$b[11]] assigns values to the array $a. The fact that you (and, 
probably, most of us) can't tell right off the bat is a clear sign 
that this is a bad idea, because it's ambiguous and confusing.

The same line using the current syntax, btw, would have looked like this:

$a = array (1,3,$b[11]);
Actually, $a = [1,2,$b[11]] would be amazingly clear and expressive in 
comparison with the rather verbose array() version (same thing with the 
swap, btw).
I guess we'll have to agree to disagree :)

$a = [1,2,$b[11]] is semantically inconsistent.

As you can see the ambiguity is gone--square brackets are used for one 
purpose and nothing else.
Actually, do you realize that you use () both for grouping and for 
application? I can't see anything wrong with using square brackets for 
array element access and array creation, to be honest.
Actually, no, I don't. I'm not sure what grouping and application 
mean...

Mt.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Michael Walter
I like some of the Python syntax. But some of it is cumbersome. Same 
with PHP. But I think PHP is closer to what I want so what's wrong with 
trying to improve it where it's possible (and easily done)?


agree, and you can easily make PHP code not readable with such improvements.
again, I can't understand why PHP should have another way of creating new arrays.
there are so many things you can improve in PHP - why did you choose to change the 
syntax?
Cause array() really is used very often, and could be made much more 
pretty (read: readable, expressive) with [].

Cheers,
Michael
PS: there was static without the keyword in ZE1.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Michael Walter
I guess we'll have to agree to disagree
$a = [1,2,$b[11]] is semantically inconsistent. 
Yeah, I agree to disagree on that one, too :)

Actually, do you realize that you use () both for grouping and for 
application? I can't see anything wrong with using square brackets for 
array element access and array creation, to be honest.


Actually, no, I don't. I'm not sure what grouping and application 
mean...
$a*(1+2) vs. $a(1+2)

Grouping (not really a good term, I'm sorry) in the sense of 
determining the order of evaluation.

Application being normal function application (function call).

Cheers,
Michael
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread George Schlossnagle
On Nov 5, 2003, at 12:54 PM, Jani Taskinen wrote:

On Wed, 5 Nov 2003, Andi Gutmans wrote:

At 11:58 AM 11/5/2003 -0500, George Schlossnagle wrote:

is that any less clear than

$a = array(array(1,2,3), array(1 = array(1,3,2,2), array(a =
array(array(1,2,3,4), 4, array(1,2)));
Both examples can be made crystal clear with appropriate whitespace.
I agree with that.
So it's gonna be the pythonized version? ie. if there is no
appropriate whitespace - parse error? :)
The point was that the example was unreadable even if translated 
directly into syntactical PHP.  To make it 'readable', you need to add 
whitespace, which would in fact make either syntax quite readable.  
Anything can look like crap if you want it to.

George

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Andrei Zmievski
On Wed, 05 Nov 2003, Ford, Mike   [LSS] wrote:
 On 05 November 2003 16:48, Ilia Alshanetsky contributed these pearls of
 wisdom:
 
  I mean c'mon, is 5 characters that much of a problem and is
  absolute code clarity not worth those 5 characters? Character
  efficiency is done in Perl, where you can do things like ~=
  and @_, but that makes Perl code naturally obfuscated and I do
  not think that's a good way to go. 
 
 I don't think the number of characters is the main issue here -- it's about
 having a *nicer* set of characters.  Personally, I'd be still be in favour
 (although not quite as much) if the proposed syntax were [[[1,2,3]]] -- for
 me, it's about having a syntax that shouts *ARRAY* rather than whispers it.

And array() steps too softly for you?

- Andrei

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread George Schlossnagle
On Nov 5, 2003, at 1:29 PM, Marco Tabini wrote:
$a = [1,2,$b[11]] is semantically inconsistent.
How so?  Is

foo(array(1,2));

semantically inconsistent?  On one hand () is used with a language 
construct (array()), whereas in the other context it indicates 
arguments to a function.  I think that is what he meant by 'grouping' 
and 'application'.

Similar tokens have different syntactical meaning all over the 
language.  Compare '' and ''.  To me that is no diffent that 
variable[] and [].

George (still -1, but because it makes for unmaintainable code, not 
because it's hard to read)

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Marco Tabini
George Schlossnagle wrote:
On Nov 5, 2003, at 1:29 PM, Marco Tabini wrote:

$a = [1,2,$b[11]] is semantically inconsistent.


How so?  Is

I think I've already explained why.

foo(array(1,2));

semantically inconsistent?  On one hand () is used with a language 
construct (array()), whereas in the other context it indicates arguments 
to a function.  I think that is what he meant by 'grouping' and 
'application'.

Actually, I think it meant something else. In any case, semantically you 
can still think of array() as a function (until you throw in key 
declarations, of course ;) )

Similar tokens have different syntactical meaning all over the 
language.  Compare '' and ''.  To me that is no diffent that 
variable[] and [].
Again, that's not a good reason to introduce more.

Mt.

George (still -1, but because it makes for unmaintainable code, not 
because it's hard to read)

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Shane Caraveo


+1 for the [] syntax.  I also feel it's much more intuitive.  Calling 
(what looks like) a function to make an array seems plain silly to me.

Shane

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Michael Walter
Marco Tabini wrote:
George Schlossnagle wrote:

On Nov 5, 2003, at 1:29 PM, Marco Tabini wrote:

$a = [1,2,$b[11]] is semantically inconsistent.


How so?  Is

I think I've already explained why.
Not really understandable, though.


foo(array(1,2));

semantically inconsistent?  On one hand () is used with a language 
construct (array()), whereas in the other context it indicates 
arguments to a function.  I think that is what he meant by 'grouping' 
and 'application'.

Actually, I think it meant something else. In any case, semantically you 
can still think of array() as a function (until you throw in key 
declarations, of course ;) )
Yup, I told you I meant something different (although on the same line 
of reasoning). I think you misunderstand semantics, anyway. You should 
not think of array() as a function, as basically everything else except 
to the syntax is different to real functions, consider 
call_user_func('array', 1, 2, 3) or array_map('array', array(1, 2, 3), 
array(Foo, Bar, Baz));

How much better would look map('array', [1..3], [Foo, Bar, Baz]); 
anyway.. (although we really should not argue about that, as it's simply 
taste).

Similar tokens have different syntactical meaning all over the 
language.  Compare '' and ''.  To me that is no diffent that 
variable[] and [].


Again, that's not a good reason to introduce more.
That is a statement backed up by good argumentation. :)

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Robert Cummings
On Wed, 2003-11-05 at 14:03, David Enderson wrote:
 
 I believe the ultimate goal of PHP is to have a quick and dirty
 language that is easy to read, use, and learn.  While Rasmus's comment

I complete disagree with the quick and dirty statement. Maybe at one
time, but I think a lot of effort has gone into PHP in recent years to
entertain consistency and quality. As for the new syntax, *shrug*, I'm
happy with the array() function syntax, but could care less if it were
implemented. I guess I'm -0 :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread David Enderson
Robert,

And I don't agree with it either.  I like quick, but I don't like dirty.
I just thought from what I'd read on this list over the last year that
it was a goal.  You may be correct that I misinterpreted the current
goals of the language, and I'll be happy if you are right.  :-)

--David

 -Original Message-
 From: Robert Cummings [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, November 05, 2003 3:09 PM
 To: David Enderson
 Cc: [EMAIL PROTECTED]
 Subject: RE: [PHP-DEV] Proposal: Array syntax
 
 
 On Wed, 2003-11-05 at 14:03, David Enderson wrote:
  
  I believe the ultimate goal of PHP is to have a quick and dirty 
  language that is easy to read, use, and learn.  While 
 Rasmus's comment
 
 I complete disagree with the quick and dirty statement. 
 Maybe at one time, but I think a lot of effort has gone into 
 PHP in recent years to entertain consistency and quality. As 
 for the new syntax, *shrug*, I'm happy with the array() 
 function syntax, but could care less if it were implemented. 
 I guess I'm -0 :)
 
 Cheers,
 Rob.
 -- 
 ..
 | InterJinn Application Framework - http://www.interjinn.com |
 ::
 | An application and templating framework for PHP. Boasting  | a 
 | powerful, scalable system for accessing system services  | such as 
 | forms, properties, sessions, and caches. InterJinn |
 | also provides an extremely flexible architecture for   |
 | creating re-usable components quickly and easily.  |
 `'
 

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Sara Golemon
FWIW- (And I understand I'm late chiming in on this thread)

 I'm -1 on this syntax.

 It's Perlish and ugly.  It is *not* PHP syntax.

-Sara

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread George Schlossnagle
On Nov 5, 2003, at 5:41 PM, Sara Golemon wrote:

FWIW- (And I understand I'm late chiming in on this thread)

 I'm -1 on this syntax.

 It's Perlish and ugly.  It is *not* PHP syntax.
To continue to play devils advocate, I actually find it C-ish and nice:

char foo[] = { a, b, c i told you so};

George (thinking [] is pretty but disliking alternative syntaxes)

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Wez Furlong
 Anyway, it's no biggy and if most people here think it shouldn't be added
 then that's fine with me.

Thies reminded me of something that should be considered here; we talked
about
and alternative array syntax for overloaded objects where all the array
indices are
required in one chunk to be able to resolve an overloaded array lookup.

eg: in COM, if you have a 2-Dimensional SafeArray, and you want to lookup an
element, you need to provide both dimension offsets at the same time.

$foo = $arr[0][1];

This cannot be acheived with the current breadcumb evaluation used by the
engine, as the engine will try to resolve $tmp = $arr[0]; $foo = $tmp[1];

One of the possible solutions was the pascal style array indexing:

$foo = $arr[0,1];

If we overload [] too much, we really will end up with unmaintainable code.

I'm -1 on the alternative array declaration syntax unless we implement the
pascal syntax (or something else useful!) for ZE2 OO handlers, in which
case I'm -0.

--Wez.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Christian Schneider
George Schlossnagle wrote:
George (thinking [] is pretty but disliking alternative syntaxes)
Ok, let me recap my short visit on this mailing list:
1) Dangling commas in function calls were considered bloat
2) Adding the local vars to debug_backtrace() was silently ignored
3) A prettier array syntax was discarded because it's an alternative
On the other hand Sara Golemon wrote:
 It's Perlish and ugly.  It is *not* PHP syntax.
while e.g. private, catch, throw, final were introduced which are 
Javaesque and ugly. They are *not* PHP spirit of a simple language. But 
I didn't complain.

After all this I guess I have to maintain my own PHP branch and hope for 
PHP6 to address some of my issues. Or switch to another language at some 
point, because a language to me is a tool, not a religion.

Anyway, I wish everybody happy hacking,
- Chris
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Ard Biesheuvel
After all this I guess I have to maintain my own PHP branch and hope for 
PHP6 to address some of my issues. Or switch to another language at some 
point, because a language to me is a tool, not a religion.
This is exactly the point. Why waste so much energy on deciding how to 
spell out your array definitions. The decision has been made a long time 
ago to use the array() syntax. Adding alternatives adds nothing but the 
ability to save a few key strokes. (Personally, I would have preferred 
the [] syntax, BTW)

Try/catch however are a fundamental extension to the functionality of 
the language. Adding these was a good idea in my opinion. Borrowing the 
syntax from Java/C++ was an obvious choice.

I can't believe you would seriously consider maintaining your own PHP 
branch, only to be able to use dangling commas and [] array syntax.

-1 on both the array syntax and dangling comma issues.

--
Ard
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-05 Thread Christian Schneider
Ard Biesheuvel wrote:
spell out your array definitions. The decision has been made a long time 
ago to use the array() syntax. Adding alternatives adds nothing but the 
I was under the impression that syntax changes are possible. Silly me.

Try/catch however are a fundamental extension to the functionality of 
I couldn't disagree more. I don't think the language really needed it 
but I'm on my own here, I know.

I can't believe you would seriously consider maintaining your own PHP 
branch, only to be able to use dangling commas and [] array syntax.
Luckily all my patches are in the 2 to 10 lines range so 'maintain' is 
too big a word for it. It was done once and I can benefit in all my 
(thousands of lines of) PHP code now. The Apache/PHP build script 
already has hooks for patches so little effort, big impact. The joy of 
open source.

I was trying to give something back to the community but the community 
didn't want it. Tough luck. PHP (and me) are going to survive it :-)

- Chris

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-04 Thread Ken Tossell
Christian Schneider wrote:

Note: I checked the newsgroup archive but couldn't find a discussion 
about this. After not hearing back about my proposed enhancement to 
debug_backtrace() and the dangling comma for function call parameters 
being rejected I wonder if I'm using the right mailing list for this :-) 
You're on the right list. If you don't get any more responses, it's just 
because something's wrong with your idea. ;-)

Looks cool, though I've never touched ZE2 and, sadly, have no knowledge 
of the parser...

Ken

- Chris

[patch]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Proposal: Array syntax

2003-11-04 Thread Rasmus Lerdorf
More magic.  The difference between these two lines:

$a = array(1,2,3);
$a = [ 1,2,3 ];

is that with the first you can go and look up the array keyword and see 
what it does, whereas on the second line you have no idea.  You can't look 
up a [

You are right that arrays are common and that this might be a case to 
break the no-magic PHP rule, but I am personally not in favour of breaking 
it for this case.  

-Rasmus

On Wed, 5 Nov 2003, Christian Schneider wrote:

 I propose to add an alternative (backward compatible) short array 
 creation syntax:
 $a = [ 1, 2, 3 ]; and $a = [ 'a' = 42, 'b' = foo ];
 
 It can also be used in function calls:
 img(['src' = logo.gif, 'alt' = Logo]);
 
 Reason behind this change: Arrays are used a lot and should therefore 
 have as little syntactic overhead as possible. And I think the short 
 syntax is also easier to read and write.
 
 A patch for the parser is trivial and is attached for Zend2.
 
 Note: I checked the newsgroup archive but couldn't find a discussion 
 about this. After not hearing back about my proposed enhancement to 
 debug_backtrace() and the dangling comma for function call parameters 
 being rejected I wonder if I'm using the right mailing list for this :-)
 
 - Chris
 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php