Hi:
Call for voting for "Allow use T_AS
in closure use statement",
https://wiki.php.net/rfc/useas#voting
any comment will be appreciated.
thanks
--
Laruence Xinchen Hui
http://www.laruence.com/
I missed the discussion on this one, the RFC examples are very simple. Does
it support aliasing array indices?
For example: (use $matches[0] as $name)
Hi:
Call for voting for "Allow useT_AS
in closure use statement",
https://wiki.php.net/rfc/useas#votingany comment will be appreciated.
thanks
--
Laruence Xinchen Hui
http://www.laruence.com/
I missed the discussion on this one, the RFC examples are very simple. Does
it support aliasing array indices?For example: (use $matches[0] as $name)
sorry, no, it's only support literal variable for now.
thanks
Hi:
Call for voting for "Allow useT_AS
in closure use statement",
https://wiki.php.net/rfc/useas#votingany comment will be appreciated.
thanks
--
Laruence Xinchen Hui
http://www.laruence.com/--
--
Laruence Xinchen Hui
http://www.laruence.com/
Hi:
I saw you two vote against for this RFC.
could you explain why? then maybe I can improve it.
thanks
I missed the discussion on this one, the RFC examples are very simple. Does
it support aliasing array indices?For example: (use $matches[0] as $name)
sorry, no, it's only support literal variable for now.thanks
Hi:
Call for voting for "Allow useT_AS
in closure use statement",
https://wiki.php.net/rfc/useas#votingany comment will be appreciated.
thanks
--
Laruence Xinchen Hui
http://www.laruence.com/--
--
Laruence Xinchen Hui
http://www.laruence.com/
--
Laruence Xinchen Hui
http://www.laruence.com/
Hi:
I saw you two vote against for this RFC.could you explain why? then maybe I can improve it.
thanks
I can't speak for them, but it might have something to do with a lack of
information. I don't recall seeing the discussion thread on this, either.
Though I could've just missed it. More specifics I think would be helpful.
--Kris
Laruence,
Hi:
I saw you two vote against for this RFC.could you explain why? then maybe I can improve it.
thanks
The reason that I voted against it is simple. It's sugar to make it harder
to understand what the code is doing, and blur the line of what the closure
is doing.
Closures are supposed to "wrap" a parent scope (in other words, "close in
on it"). The closure isn't a strictly new scope, but an extension on the
existing one. PHP muddied this concept with the USE declaration (rather
than importing the parent scope in its entirety, as almost every other
language does). But this change would muddy it even further.
My argument would be that if you really need to rename variables for
clarity, you don't belong putting it in a closure in the first place (as
it's way too much logic that needs to be split out into a separate function
entirely).
Additionally, it will further confuse the subject because:
$f = function() use ($this as $obj) {
$obj->protectedMethod(); // fatal error, as it's not in the same scope
}
That will fail for non-obvious reasons. At least currently there's an extra
level of indirection required to pass $this, so it's a little bit clearer
that you're not passing $this
to the object, but a copy of it.
Additionally, we need to think about the coupling between the closure's
scope and the parent scope. There is -by design- very tight coupling
between them. And not even from a language level. The closure is defined
inside of another function, at a specific point in execution to use
certain aspects of the parent scope. That means that it's highly coupled to
the parent function. Actually, it's has cohesion in almost all forms:
Logical, Temporal, Procedural, Communicational, Sequential and Functional.
The only form of cohesion that it doesn't directly and automatically have
is Coincidental... Therefore, their scopes are always going to be tightly
coupled (which is what we want with a closure).
If you really need to rename variables into the closure, create a factory
for the closure:
$closureFactory = function ($a, $b, $c) {
return function() use ($a, $b, $c) {
};
};
Yes, it's an extra level of indirection, but that indirection is explicit
rather than implied....
So, I guess in summary, I would say that I voted against it because it
further blurs the line between what a closure is and what PHP implements
(which is already fairly blurry).
That's my $0.02 at least...
Anthony
I missed the discussion on this one, the RFC examples are very simple. Does
it support aliasing array indices?
I have missed the discussion two.
I can't vote but I don't feel confortable with this new notation.
Wouldn't be better to make the “=” operator available in use()? It has
the same semantics, no?
Best regards :-).
For example: (use $matches[0] as $name)
Hi:
Call for voting for "Allow useT_AS
in closure use statement",
https://wiki.php.net/rfc/useas#votingany comment will be appreciated.
thanks
--
Laruence Xinchen Hui
http://www.laruence.com/--
--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/
PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://disc.univ-fcomte.fr/ and http://www.inria.fr/
Member of HTML and WebApps Working Group of W3C
http://w3.org/
Did the voting close already? One day seems awfully short. :(
Hi:
Call for voting for "Allow useT_AS
in closure use statement",
https://wiki.php.net/rfc/useas#votingany comment will be appreciated.
thanks
--
Laruence Xinchen Hui
http://www.laruence.com/
Did the voting close already? One day seems awfully short. :(
Laruence closed the vote because he wanted to add aliasing of
arbitrary expressions instead of just variables.
Nikita
Hi!
Call for voting for "Allow use `T_AS` in closure use statement",
https://wiki.php.net/rfc/useas#voting
any comment will be appreciated.
I think it would be useful to add some explanation why this change is
useful, with specific code examples that it improves. Right now it seems
to be lacking good use cases so it's not clear why one would need this -
i.e., just renaming the variable doesn't seem all that important...
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
On Sat, Jul 21, 2012 at 1:02 AM, Stas Malyshev smalyshev@sugarcrm.comwrote:
Hi!
Call for voting for "Allow use `T_AS` in closure use statement",
https://wiki.php.net/rfc/useas#voting
any comment will be appreciated.
I think it would be useful to add some explanation why this change is
useful, with specific code examples that it improves. Right now it seems
to be lacking good use cases so it's not clear why one would need this -
i.e., just renaming the variable doesn't seem all that important...
For starters, maybe we could use a few examples from the previous thread
about this rfc:
internals@lists.php.net/msg57855.html" rel="nofollow" target="_blank">http://www.mail-archive.com/internals@lists.php.net/msg57855.html
I really liked the one example from Jordi (
internals@lists.php.net/msg57904.html" rel="nofollow" target="_blank">http://www.mail-archive.com/internals@lists.php.net/msg57904.html)
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
Hi!
For starters, maybe we could use a few examples from the previous thread
about this
rfc: internals@lists.php.net/msg57855.html" rel="nofollow" target="_blank">http://www.mail-archive.com/internals@lists.php.net/msg57855.html
I really liked the one example from Jordi
(internals@lists.php.net/msg57904.html" rel="nofollow" target="_blank">http://www.mail-archive.com/internals@lists.php.net/msg57904.html)
This is exactly the thing that should be on the RFC :)
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
hi Laruence,
Hi:
Call for voting for "Allow useT_AS
in closure use statement",
https://wiki.php.net/rfc/useas#votingany comment will be appreciated.
Well, that's why the discussions period is required.
Please close the vote, begin a discussion period (2 weeks minimum),
then go ahaed again for a vote once there you are done with the
discussions.
Cheers,
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org
hi Laruence,
Hi:
Call for voting for "Allow useT_AS
in closure use statement",
https://wiki.php.net/rfc/useas#votingany comment will be appreciated.
Well, that's why the discussions period is required.
Please close the vote, begin a discussion period (2 weeks minimum),
then go ahaed again for a vote once there you are done with the
discussions.
Pierre:
actually, I proposed this 3month ago, but yeah,
I have closed this vote, will proposal it again after I implement
the dynamic variable supporting :)
thanks
Cheers,
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org
--
Laruence Xinchen Hui
http://www.laruence.com/