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 <tendo...@gmail.com>: > Forgot something in the previous post... > > On Fri, Jan 26, 2018 at 12:16 PM, Christian Schneider < > cschn...@cschneid.com > > 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 someone else finds more good uses: > > > > 1) Emulating named parameters with associative arrays like > > html::img([ 'src' => $src, 'alt' => $alt ]); > > could be written as > > html::img([ :$src, :$alt ]); > > which encourages consistent naming of variables and parameters > > > > The most similar extant feature to this is compact, but it's not as compact > as this syntax. > > $src = 'my.jpg'; > $alt = 'My alt'; > html::img(compact($src, $alt)); > > will accomplish the same thing since compact does the reverse of extract - > it pulls the specified variables from the local scope and puts them into an > associative array. > -- David Rodrigues