Re: [PHP-DEV] Shorthand proposal for associative arrays

2018-01-27 Thread Andrey Andreev
Hi, I've got mixed feelings about this ... On one hand, I've always avoided compact() because it is magic; a hack that was very obviously made because there was no language construct for it. This would've spared me lots of annoyance with code that was already otherwise boring. But on the other ha

Re: [PHP-DEV] Shorthand proposal for associative arrays

2018-01-27 Thread Markus Fischer
Hi, On 28.01.18 03:51, Christian Schneider wrote: 2) More importantly: It hides the variable being used: 'src' instead of $src which makes it harder to search for the variable or statically analyse the code. I'm not sure about that argument. compact() been around basically since forecer. Mod

Re: [PHP-DEV] Shorthand proposal for associative arrays

2018-01-27 Thread Christian Schneider
Am 28.01.2018 um 00:29 schrieb Sara Golemon : > On Fri, Jan 26, 2018 at 4:49 PM, David Rodrigues > wrote: >> Sorry. I mean "compact()" instead of extract() (it basically does the >> oposite hehe), I confused everything in a hurry. Sorry. >> >> So the real example is

Re: [PHP-DEV] Shorthand proposal for associative arrays

2018-01-27 Thread Sara Golemon
On Fri, Jan 26, 2018 at 4:49 PM, David Rodrigues wrote: > Sorry. I mean "compact()" instead of extract() (it basically does the > oposite hehe), I confused everything in a hurry. Sorry. > > So the real example is: html::img(compact('src', 'alt')); > > 2018-01-26 19:39 GMT-02:00 Michael Morris : >

Re: [PHP-DEV] Shorthand proposal for associative arrays

2018-01-27 Thread Rowan Collins
Hi! On 26/01/2018 18:16, Christian Schneider wrote: Hi there, I have a proposal for a shorthand notation of associative arrays borrowed from another language: :$foo would be equivalent to 'foo' => $foo and would work with array, list or [] I'm always a little suspicious of fea

Re: [PHP-DEV] Shorthand proposal for associative arrays

2018-01-26 Thread Richard Jennings
In my opinion this suggestion reduces readability and increases cognative burden and as such I hope it is not included. Regards On Fri, 26 Jan 2018 at 21:52, Fleshgrinder wrote: > On 1/26/2018 7:16 PM, Christian Schneider wrote: > > Hi there, > > I have a proposal for a shorthand notation of ass

Re: [PHP-DEV] Shorthand proposal for associative arrays

2018-01-26 Thread Fleshgrinder
On 1/26/2018 7:16 PM, Christian Schneider wrote: > Hi there, > I have a proposal for a shorthand notation of associative arrays borrowed > from another language: > :$foo > would be equivalent to > 'foo' => $foo > and would work with array, list or [] > > Motivation behind it, maybe so

Re: [PHP-DEV] Shorthand proposal for associative arrays

2018-01-26 Thread David Rodrigues
Sorry. I mean "compact()" instead of extract() (it basically does the oposite hehe), I confused everything in a hurry. Sorry. So the real example is: html::img(compact('src', 'alt')); 2018-01-26 19:39 GMT-02:00 Michael Morris : > Forgot something in the previous post... > > On Fri, Jan 26, 2018

Re: [PHP-DEV] Shorthand proposal for associative arrays

2018-01-26 Thread Michael Morris
Forgot something in the previous post... On Fri, Jan 26, 2018 at 12:16 PM, Christian Schneider wrote: > Hi there, > I have a proposal for a shorthand notation of associative arrays borrowed > from another language: > :$foo > would be equivalent to > 'foo' => $foo > and would work

Re: [PHP-DEV] Shorthand proposal for associative arrays

2018-01-26 Thread Michael Morris
On Fri, Jan 26, 2018 at 2:00 PM, David Rodrigues wrote: > Maybe you should see the extract() method. Uhm, what? You need to learn what extract does before you recommend it as an alternative to someone's proposal. Extract takes an array and moves their keys onto the local symbol table. So extr

Re: [PHP-DEV] Shorthand proposal for associative arrays

2018-01-26 Thread David Rodrigues
Sorry, the extract() function will receives an array as first argument. html::img(extract(['src', 'alt']); 2018-01-26 18:00 GMT-02:00 David Rodrigues : > Maybe you should see the extract() method. It will receive strings as > varargs and will create an associative array with the string name and

Re: [PHP-DEV] Shorthand proposal for associative arrays

2018-01-26 Thread David Rodrigues
Maybe you should see the extract() method. It will receive strings as varargs and will create an associative array with the string name and the value, similar to your first example. html::img(extract('src', 'alt')); 2018-01-26 16:16 GMT-02:00 Christian Schneider : > Hi there, > I have a proposa

[PHP-DEV] Shorthand proposal for associative arrays

2018-01-26 Thread Christian Schneider
Hi there, I have a proposal for a shorthand notation of associative arrays borrowed from another language: :$foo would be equivalent to 'foo' => $foo and would work with array, list or [] Motivation behind it, maybe someone else finds more good uses: 1) Emulating named parameters