RE: Proposal: Array syntax

php.internals

David Enderson

22 years ago
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

Sara Golemon

22 years ago
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

George Schlossnagle

22 years ago
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)

Christian Schneider

22 years ago
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

Ard Biesheuvel

22 years ago
> 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

Christian Schneider

22 years ago
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

Andi Gutmans

22 years ago
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

Kouber Saparev

22 years ago
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" <pollita@php.net> wrote in message news:20031105224100.44394.qmail@pb1.pair.com...

Mike Robinson

22 years ago
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

Alexey Trunyov

22 years ago
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.