4 ms·
I've been wanting this for a long time, seems like a no brainer to me. It'd be nice to add some of the nice syntactic sugar that other languages have. Kinda st
by TamDenholm 15y ago
I've been wanting this for a long time, seems like a no brainer to me. It'd be nice to add some of the nice syntactic sugar that other languages have.
Kinda strange that they have both readable and unreadable listed as both pro and con...
- gdulli 15y agoI don't think that a concise method of working with arrays should be thought of as syntactic sugar, not if you mean it in a pejorative way. I found array_map, array_filter, array_key_exists, array_this, array_that painful to write, but never felt that I was gaining any sort of readability for it.
- swivelmaster 15y agoWouldn't it be nice if PHP arrays acted as objects and all of those functions were methods? $newArray = $array->map("function_name"); Not gonna happen, but would be nice. Any extensions doing this?
- TamDenholm 15y agoYou could write that if you wanted, using __call, would be like 10 lines of code or something.
- swivelmaster 15y agoPhp arrays don't act as objects and have no methods, so I'm not sure what you are suggesting.
- abredow 15y agoYou can create an object that implements the ArrayAccess interface, but it doesn't extend the native array object in the traditional sense.
- TamDenholm 15y agoNo I meant "syntactic sugar" in a good way, i didnt realise it was a pejorative. I mean it as per the definition on wikipedia: Syntactic sugar is a computer science term that refers to syntax within a programming language that is designed to make things easier to read or to express, while alternative ways of expressing them exist.
- jerf 15y agoIt is not generally perjorative. Some people interpret it as automatically perjorative, feeling that any syntactic sugar must necessarily carry costs in excess of benefits, but they are in the minority. Sizable minority, but minority. Concentrations of people who dislike all syntax sugar can be found in the Forth community and concatenative languages in general, Lisp, and to a lesser extent, in the Haskell community. People who think syntax sugar is the answer to everything can be found in the Perl 5 community, and Perl 6 is arguably syntax sugar spun into cotton candy, hardened, and used to build a glorious gossamer castle in the sky, which they are currently working on landing. I have taken this metaphor too far.
- louisdefunes 15y agoFTFY: pejorative
- config_yml 15y agoThe pro/cons are arguments extracted from the mailing list. So the guys on the pro side said it was readable, the guys on the contra side said unreadable. I think it would have been a nice addition...
- soulclap 15y agoGuess this just means what's readable to one person is not necessarily readable to another.