Hello folks,
While rambling with some code today, I realized that call_user_func
behaves strangely, appearing and disappearing from stack traces depending
on versions of PHP. For an example, compare
http://3v4l.org/fGpIk#vphp7@20140901, http://3v4l.org/fGpIk#v530 and
http://3v4l.org/fGpIk#vhhvm-301.
This makes debugging code quite complicated if not just annoying and
frustrating.
Additionally, it seems like call_user_func
and similars are impacting
performance in some parts of my codebase (event dispatcher logic).
Therefore, here comes my idea of simply getting rid of call_user_func
,
call_user_func_array
, func_get_args
, func_num_args
and func_get_arg
.
My plan for it would be to add a deprecation (notice? not sure about that)
in PHP 5.7, and a complete removal of those methods in PHP 7.0.
BC compatibility is easily achieved as variadics (
https://wiki.php.net/rfc/variadics) allow for writing cleaner and less
complex versions:
- http://3v4l.org/HDQb6 (call_user_func)
- http://3v4l.org/AgEG5 (call_user_func_array)
- http://3v4l.org/O3G6T (func_get_args) (broken in HHVM)
- http://3v4l.org/vcYso (func_get_arg) (broken in HHVM)
- http://3v4l.org/cg8i0 (func_num_args) (broken in HHVM)
Those files could moved to a library and included when running on legacy
codebases. Eventually, grepping for those function calls is also trivial.
Here's also the example with the exception and the userland implementation
of call_user_func
, which has a much more readable/clear/inspectable stack
trace: http://3v4l.org/i4G8c
Thoughts? If this idea gets enough traction, I'd gladly go and ask for
karma, open an RFC and eventually provide a patch if I'm able to.
Greets,
Marco Pivetta
While rambling with some code today, I realized that
call_user_func
behaves strangely, appearing and disappearing from stack traces depending
on versions of PHP. For an example, compare
http://3v4l.org/fGpIk#vphp7@20140901, http://3v4l.org/fGpIk#v530 and
http://3v4l.org/fGpIk#vhhvm-301.
IIRC this is a bug caused by PHP7 eliminating the call to the function entirely, and instead inserting a normal function call opcode. See: https://github.com/php/php-src/blob/292421d3a1fcefe88c3017ffdb9f889c39a6c8c1/Zend/zend_compile.c#L2777
This could possibly be fixed somehow.
Additionally, it seems like
call_user_func
and similars are impacting
performance in some parts of my codebase (event dispatcher logic).
In PHP 7, due to the function call removal, it should be just the same, performance-wise, as a normal function call.
Therefore, here comes my idea of simply getting rid of
call_user_func
,
call_user_func_array
,func_get_args
,func_num_args
andfunc_get_arg
.My plan for it would be to add a deprecation (notice? not sure about that)
in PHP 5.7, and a complete removal of those methods in PHP 7.0.BC compatibility is easily achieved as variadics (
https://wiki.php.net/rfc/variadics) allow for writing cleaner and less
complex versions:
“Easily” achieved? No. This would break an awful, awful lot of existing PHP code with no gain. There’s no need to deprecate it any time soon. The variadics syntax is merely a nicer alternative. We should not force people to rewrite existing code to use it. There is absolutely no need to get rid of func_get_args.
I would vote against any such proposal, and I hope others on the list would join me in doing so.
--
Andrea Faulds
http://ajf.me/
While rambling with some code today, I realized that
call_user_func
behaves strangely, appearing and disappearing from stack traces depending
on versions of PHP. For an example, compare
http://3v4l.org/fGpIk#vphp7@20140901, http://3v4l.org/fGpIk#v530 and
http://3v4l.org/fGpIk#vhhvm-301.IIRC this is a bug caused by PHP7 eliminating the call to the function
entirely, and instead inserting a normal function call opcode. See:
https://github.com/php/php-src/blob/292421d3a1fcefe88c3017ffdb9f889c39a6c8c1/Zend/zend_compile.c#L2777This could possibly be fixed somehow.
Additionally, it seems like
call_user_func
and similars are impacting
performance in some parts of my codebase (event dispatcher logic).In PHP 7, due to the function call removal, it should be just the same,
performance-wise, as a normal function call.Therefore, here comes my idea of simply getting rid of
call_user_func
,
call_user_func_array
,func_get_args
,func_num_args
and
func_get_arg
.My plan for it would be to add a deprecation (notice? not sure about
that)
in PHP 5.7, and a complete removal of those methods in PHP 7.0.BC compatibility is easily achieved as variadics (
https://wiki.php.net/rfc/variadics) allow for writing cleaner and less
complex versions:“Easily” achieved? No. This would break an awful, awful lot of existing
PHP code with no gain. There’s no need to deprecate it any time soon. The
variadics syntax is merely a nicer alternative. We should not force people
to rewrite existing code to use it. There is absolutely no need to get rid
of func_get_args.I would vote against any such proposal, and I hope others on the list
would join me in doing so.--
Andrea Faulds
http://ajf.me/--
Agreed. The call_user_func()
and call_user_func_array()
functions are used
all over the place. I see absolutely no gain, whatsoever in removing them
and forcing developers to write their own userland variants instead.
--Kris
The
call_user_func()
andcall_user_func_array()
functions are used all
over the place. I see absolutely no gain, whatsoever in removing them and
forcing developers to write their own userland variants instead.--Kris
Of course they are, but that's obviously because any codebase written so
far didn't have PHP 5.6 support :-)
The main point here is moving forward and killing API that has no use-case
anymore (and has to be maintained).
Marco Pivetta
The
call_user_func()
andcall_user_func_array()
functions are used all over the place. I see absolutely no gain, whatsoever in removing them and forcing developers to write their own userland variants instead.--Kris
Of course they are, but that's obviously because any codebase written so far didn't have PHP 5.6 support :-)
The main point here is moving forward and killing API that has no use-case anymore (and has to be maintained).
PHP 5.6 has been out for less than two months. Let’s say PHP 7 comes out in 18 months’ time, so June 2016. Even then, PHP 5.6 would have been around for less than 20 months. It is incredibly unreasonable to suggest that application developers should move to this new API and completely suspend usage of the previous one in such a short timespan (especially given how few people will have moved to 5.6 by then) for a non-security fix.
--
Andrea Faulds
http://ajf.me/
PHP 5.6 has been out for less than two months. Let’s say PHP 7 comes out
in 18 months’ time, so June 2016. Even then, PHP 5.6 would have been around
for less than 20 months. It is incredibly unreasonable to suggest that
application developers should move to this new API and completely suspend
usage of the previous one in such a short timespan (especially given how
few people will have moved to 5.6 by then) for a non-security fix.
Assuming PHP 7.0 came out in 2 years from now, I don't expect a decent
adoption rate anyway for the next 5 years.
Even in such a case, isn't it possible to have PHP "include" the polyfill
from an actual location instead of basing the function definition on some
internals voodoo?
Marco Pivetta
Assuming PHP 7.0 came out in 2 years from now, I don't expect a decent
adoption rate anyway for the next 5 years.
So you want to decrease adoption rate even more for a very small win?
Fantastic (irony!)
johannes
While rambling with some code today, I realized that
call_user_func
behaves strangely, appearing and disappearing from stack traces depending
on versions of PHP. For an example, compare
http://3v4l.org/fGpIk#vphp7@20140901, http://3v4l.org/fGpIk#v530 and
http://3v4l.org/fGpIk#vhhvm-301.IIRC this is a bug caused by PHP7 eliminating the call to the function
entirely, and instead inserting a normal function call opcode. See:
https://github.com/php/php-src/blob/292421d3a1fcefe88c3017ffdb9f889c39a6c8c1/Zend/zend_compile.c#L2777This could possibly be fixed somehow.
Having the stack trace entry there would be enough too.
Additionally, it seems like
call_user_func
and similars are impacting
performance in some parts of my codebase (event dispatcher logic).In PHP 7, due to the function call removal, it should be just the same,
performance-wise, as a normal function call.
Good to know! And I suppose no additional stack frame is created either?
Therefore, here comes my idea of simply getting rid of
call_user_func
,
call_user_func_array
,func_get_args
,func_num_args
and
func_get_arg
.My plan for it would be to add a deprecation (notice? not sure about
that)
in PHP 5.7, and a complete removal of those methods in PHP 7.0.BC compatibility is easily achieved as variadics (
https://wiki.php.net/rfc/variadics) allow for writing cleaner and less
complex versions:“Easily” achieved? No. This would break an awful, awful lot of existing
PHP code with no gain. There’s no need to deprecate it any time soon. The
variadics syntax is merely a nicer alternative. We should not force people
to rewrite existing code to use it. There is absolutely no need to get rid
of func_get_args.I would vote against any such proposal, and I hope others on the list
would join me in doing so.
I'd actually just deprecate any API for which there isn't a use-case
anymore, but that's my own vision.
As I've already demonstrated, a polyfill already exists and is easy to
implement/use too. Exactly like what happened with register_globals
(which is much harder to find), it would be a small addition at the
beginning of <whatever-legacy-thing> you are using.
Could you elaborate a bit on this?
Marco Pivetta
I would vote against any such proposal, and I hope others on the list
would join me in doing so.
I fully agree with you here.
Hello folks,
While rambling with some code today, I realized that
call_user_func
behaves strangely, appearing and disappearing from stack traces depending
on versions of PHP. For an example, compare
http://3v4l.org/fGpIk#vphp7@20140901, http://3v4l.org/fGpIk#v530 and
http://3v4l.org/fGpIk#vhhvm-301.
Ok. Knee jerk reaction is +1 for consistency, we should decide on what
is the expected and accepted behaviour and make sure tests are written
so that we don't deviate from that.
Therefore, here comes my idea of simply getting rid of
call_user_func
,
call_user_func_array
,func_get_args
,func_num_args
andfunc_get_arg
.My plan for it would be to add a deprecation (notice? not sure about that)
in PHP 5.7, and a complete removal of those methods in PHP 7.0.
I understand your impulse, but I agree with others, these are far too
widely used to be deprecated like this
BC compatibility is easily achieved as variadics (
https://wiki.php.net/rfc/variadics) allow for writing cleaner and less
complex versions:
True.
So can we make these functions behave as if variadics were used
without removing them? Something akin to making these functions
language constructs?
BC compatibility is easily achieved as variadics (
https://wiki.php.net/rfc/variadics) allow for writing cleaner and less
complex versions:True.
So can we make these functions behave as if variadics were used
without removing them? Something akin to making these functions
language constructs?
That would actually be worse, as it wouldn't be possible to pass them to
methods with a callable
hint or similars such as array_map
.
In general, I understand why there's a lot of fuss about BC compat here,
but I don't see why providing them as separate file or using something like
a "global include" is a problem. Is/would something like that (be) possible
via ini setting?
Marco Pivetta
That would actually be worse, as it wouldn't be possible to pass them to
methods with acallable
hint or similars such asarray_map
.
That sounds like a good counter to your own argument that there is no
use-case for these functions. Indeed, there are plenty of use cases for
call_user_func()
and call_user_func_array()
which have nothing
whatsoever to do with variadics, so are as valid as they ever were.
func_get_args()
and func_num_args()
, OTOH, existed solely to support
variadics, and anything taking advantage of them being functions rather
than a language structure would have to be quite exotic and arcane, so
in principle they could, eventually, be removed, but I agree with others
that it's far too soon to remove a feature which has been around since
4.0 just becuase 5.6 includes a better alternative.
In general, I understand why there's a lot of fuss about BC compat here,
but I don't see why providing them as separate file or using something like
a "global include" is a problem. Is/would something like that (be) possible
via ini setting?
If they're included in the core distribution, then why make them
optional at all? If it's just a question of how the functions behave,
then surely an included (and C-level) implementation should be sought
which has the better behaviour?
Regards,
--
Rowan Collins
[IMSoP]
func_get_args()
andfunc_num_args()
, OTOH, existed solely to support variadics, and anything taking advantage of them being functions rather than a language structure would have to be quite exotic and arcane, so in principle they could, eventually, be removed, but I agree with others that it's far too soon to remove a feature which has been around since 4.0 just becuase 5.6 includes a better alternative.
They have some (admittedly limited) use beyond variadics. If you make a function and later make it redirect to another, you can preserve your typehints by using func_get_args()
rather than using the … syntax.
If they're included in the core distribution, then why make them optional at all? If it's just a question of how the functions behave, then surely an included (and C-level) implementation should be sought which has the better behaviour?
This matches my own thoughts. There is nothing wrong with these functions. There are just some issues with their implementation. We do not need to get rid of the functions, that would be an absurd overreaction. We should just fix the implementations.
Andrea Faulds
http://ajf.me/
func_get_args()
andfunc_num_args()
, OTOH, existed solely to support
variadics, and anything taking advantage of them being functions rather
than a language structure would have to be quite exotic and arcane, so in
principle they could, eventually, be removed, but I agree with others that
it's far too soon to remove a feature which has been around since 4.0 just
becuase 5.6 includes a better alternative.They have some (admittedly limited) use beyond variadics. If you make a
function and later make it redirect to another, you can preserve your
typehints by usingfunc_get_args()
rather than using the … syntax.
Can anyone come up with those use-cases? If there is something that
func_get_args()
can do and that can't be done with the code examples that
I've pasted before, then I'm missing some bits of information that may make
the entire proposal moot.
If they're included in the core distribution, then why make them
optional at all? If it's just a question of how the functions behave, then
surely an included (and C-level) implementation should be sought which has
the better behaviour?This matches my own thoughts. There is nothing wrong with these functions.
There are just some issues with their implementation. We do not need to get
rid of the functions, that would be an absurd overreaction. We should just
fix the implementations.
The point is removing more API from core and moving it to userland.
API implemented in core needs to be maintained by core devs, and is
non-transparent to consumers (reflection/debugging/etc).
In general, I've always been against any non-language feature that isn't
implemented with the language itself, but it's my point of view: as a
simple rule of thumb (my rule, many would just say I'm crazy), if it can be
implemented in PHP, then don't add it to core or extensions.
I would suggest the same deprecation approach for many array_*
functions,
but I assume that I'd only start a giant shitstorm (pardon the wording, but
that's the most precise term for that) about performance.
Anyway, it's clear that this proposal has short legs, and won't get
anywhere in a vote.
Greets,
Marco Pivetta
The point is removing more API from core and moving it to userland.
API implemented in core needs to be maintained by core devs, and is
non-transparent to consumers (reflection/debugging/etc).
In general, I've always been against any non-language feature that isn't
implemented with the language itself, but it's my point of view: as a
simple rule of thumb (my rule, many would just say I'm crazy), if it can be
implemented in PHP, then don't add it to core or extensions.
For adding features that is a good rule. For removing not. Even less
for a feature with more than a million hits on GitHub ...
https://github.com/search?l=php&q=func_get_args&type=Code&utf8=%E2%9C%93
(while that metric is bad - too many duplicates due to forks and from
phpt test suite, but still a notable number)
johannes
func_get_args()
andfunc_num_args()
, OTOH, existed solely to support
variadics, and anything taking advantage of them being functions rather
than a language structure would have to be quite exotic and arcane, so in
principle they could, eventually, be removed, but I agree with others that
it's far too soon to remove a feature which has been around since 4.0 just
becuase 5.6 includes a better alternative.They have some (admittedly limited) use beyond variadics. If you make a
function and later make it redirect to another, you can preserve your
typehints by usingfunc_get_args()
rather than using the … syntax.Can anyone come up with those use-cases? If there is something that
func_get_args()
can do and that can't be done with the code examples that
I've pasted before, then I'm missing some bits of information that may make
the entire proposal moot.If they're included in the core distribution, then why make them
optional at all? If it's just a question of how the functions behave, then
surely an included (and C-level) implementation should be sought which has
the better behaviour?This matches my own thoughts. There is nothing wrong with these functions.
There are just some issues with their implementation. We do not need to get
rid of the functions, that would be an absurd overreaction. We should just
fix the implementations.The point is removing more API from core and moving it to userland.
API implemented in core needs to be maintained by core devs, and is
non-transparent to consumers (reflection/debugging/etc).
In general, I've always been against any non-language feature that isn't
implemented with the language itself, but it's my point of view: as a
simple rule of thumb (my rule, many would just say I'm crazy), if it can be
implemented in PHP, then don't add it to core or extensions.
I would suggest the same deprecation approach for manyarray_*
functions,
but I assume that I'd only start a giant shitstorm (pardon the wording, but
that's the most precise term for that) about performance.
Yep, rewriting array_ functions in PHP will hit a very huge VM
overhead and drop the function's performance dramatically.
For func_get_args()
and call_user_func()
, we could add a deprecation
notice to PHP7 to tell people there are "better" ways of doing this
now.
Julien.P
func_get_args()
andfunc_num_args()
, OTOH, existed solely to support
variadics, and anything taking advantage of them being functions rather
than a language structure would have to be quite exotic and arcane, so in
principle they could, eventually, be removed, but I agree with others that
it's far too soon to remove a feature which has been around since 4.0 just
becuase 5.6 includes a better alternative.They have some (admittedly limited) use beyond variadics. If you make a
function and later make it redirect to another, you can preserve your
typehints by usingfunc_get_args()
rather than using the … syntax.
Can anyone come up with those use-cases? If there is something that
func_get_args()
can do and that can't be done with the code examples that
I've pasted before, then I'm missing some bits of information that may make
the entire proposal moot.
Your implementation of "userland_call_user_func" doesn't have the same
visibility as "call_user_func[_array]":
http://3v4l.org/lNgub
If they're included in the core distribution, then why make them
optional at all? If it's just a question of how the functions behave, then
surely an included (and C-level) implementation should be sought which has
the better behaviour?This matches my own thoughts. There is nothing wrong with these functions.
There are just some issues with their implementation. We do not need to get
rid of the functions, that would be an absurd overreaction. We should just
fix the implementations.The point is removing more API from core and moving it to userland.
API implemented in core needs to be maintained by core devs, and is
non-transparent to consumers (reflection/debugging/etc).
In general, I've always been against any non-language feature that isn't
implemented with the language itself, but it's my point of view: as a
simple rule of thumb (my rule, many would just say I'm crazy), if it can be
implemented in PHP, then don't add it to core or extensions.
I would suggest the same deprecation approach for manyarray_*
functions,
but I assume that I'd only start a giant shitstorm (pardon the wording, but
that's the most precise term for that) about performance.Anyway, it's clear that this proposal has short legs, and won't get
anywhere in a vote.Greets,
Marco Pivetta
Your implementation of "userland_call_user_func" doesn't have the same
visibility as "call_user_func[_array]":
http://3v4l.org/lNgub
Interesting: this seems to show that it's even more magic than I expected.
Here's just a hacked-together example, just to show that it can be done in
userland as well (there may be better ways): http://3v4l.org/QuQM1#v560
Marco Pivetta
On 13 October 2014 20:20, Marc Bennewitz <php@mabe.berlin
mailto:php@mabe.berlin> wrote:Your implementation of "userland_call_user_func" doesn't have the same visibility as "call_user_func[_array]": http://3v4l.org/lNgub
Interesting: this seems to show that it's even more magic than I expected.
Here's just a hacked-together example, just to show that it can be
done in userland as well (there may be better ways):
http://3v4l.org/QuQM1#v560
Now you have the opposite issue - you are able to call private/protected
methods but you shouldn't:
http://3v4l.org/rgmh8#v560
Marco Pivetta
Your implementation of "userland_call_user_func" doesn't have the same
visibility as "call_user_func[_array]":
http://3v4l.org/lNgubInteresting: this seems to show that it's even more magic than I
expected.Here's just a hacked-together example, just to show that it can be done
in userland as well (there may be better ways): http://3v4l.org/QuQM1#v560Now you have the opposite issue - you are able to call private/protected
methods but you shouldn't:
http://3v4l.org/rgmh8#v560
Good catch, but I'm not trying to build a complete solution in a gist: if I
do, then I'll just make a lib and include all existing .phpt
tests
related to call_user_func
, no? :-)
Just a revision of the userland version, for fun: http://3v4l.org/6IKKl#v560
Marco Pivetta
On 13 October 2014 21:18, Marc Bennewitz <php@mabe.berlin
mailto:php@mabe.berlin> wrote:On 13 October 2014 20:20, Marc Bennewitz <php@mabe.berlin <mailto:php@mabe.berlin>> wrote: Your implementation of "userland_call_user_func" doesn't have the same visibility as "call_user_func[_array]": http://3v4l.org/lNgub Interesting: this seems to show that it's even more magic than I expected. Here's just a hacked-together example, just to show that it can be done in userland as well (there may be better ways): http://3v4l.org/QuQM1#v560
Now you have the opposite issue - you are able to call private/protected methods but you shouldn't: http://3v4l.org/rgmh8#v560
Good catch, but I'm not trying to build a complete solution in a gist:
if I do, then I'll just make a lib and include all existing.phpt
tests related tocall_user_func
, no? :-)
Just a revision of the userland version, for fun:
http://3v4l.org/6IKKl#v560
Sure, but it shows that it's not a simple two-liner to have a well
working solution in userland.
The more complicated it is the more error-prone it will be and btw. slow
down.
Marco Pivetta
For the record, from https://bugs.php.net/bug.php?id=68475 :
call_user_func($a) is almost equivalent to $a():
A "foo::bar" string is OK for call_user_func()
,
but KO for the pure syntax way.
To me, this looks like a whole in the implementation that should be fixed.
But unless it happens, there will always be a valid use case for
call_user_func, since it's the only way to keep working with existing code.
Nicolas
In general, I've always been against any non-language feature that
isn't implemented with the language itself, but it's my point of view:
as a simple rule of thumb (my rule, many would just say I'm crazy), if
it can be implemented in PHP, then don't add it to core or extensions.
I think there are a few different ideas here which are worth unpacking.
Firstly, no language I can think of has ever been distributed or
standardised without a standard library of functions. We all know that
the abstractions we use could be reimplemented using lower-level
structures, but knowing that an implementation is there "out of the box"
means we don't need to spend time reinventing the wheel, or learning the
subtleties of dozens of competing wheels. Along with syntax and a type
system, the standard library is a key part of a language's identity.
Secondly, there is the question of "engine magic". I am actually rather
sympathetic to the idea that userland code should be able to access
more of the features that extension code can. For instance, object
handlers written in C can implement many more hooks than userland
objects can through magic __* methods and SPL interfaces, even when it's
not the extension's purpose to manipulate the engine. I'd love it to be
possible to write a version of SimpleXML in PHP. That said, there are
some things which really do need a close integration with the engine to
function correctly; variadics support is useful, but it clearly doesn't
allow manipulation of the actual parameter passing logic in the way a
debug extension might, and nor should it.
That does not, however, mean that all code that can be written in PHP
should be written in PHP. High-level abstractions tend to come at a
cost to performance, so it makes sense that many parts of a language's
standard library are actually written in a lower-level language - in the
case of PHP, that means implementing things in C; in the case of C, it
might mean implementing them in assembly. Sometimes, too, it just makes
more sense to keep everything in one place, such as if an extension is
binding to an existing C library, but also provides some unique
functions of its own.
Finally, there is the question of bundling and maintenance. A function
distributed with core will have to be maintained by core developers
whatever language it is written in. I guess having a section of the
standard library written in PHP might attract more people to contribute
to its maintenance, although the likely complexity of such code would
probably still be intimidating to many. There's no reason that rewriting
it in a different language would automatically make it optional - or
that keeping it in C makes it automatically compulsory. PHP already has
a modular structure, which distinguishes between mandatory, bundled, and
externally maintained "extensions", so if we really wanted a "low fat"
PHP we could just make more parts optional.
None of this should be taken as argument that anything and everything
should remain in the core, but it does add up to a rather higher bar for
removals or exclusions than "it's possible to do it another way, so we
don't need to include this way".
--
Rowan Collins
[IMSoP]
Hi!
While rambling with some code today, I realized that
call_user_func
behaves strangely, appearing and disappearing from stack traces depending
on versions of PHP.
If there's a problem with these functions, some bug in backtrace
reporting, they of course need to be fixed. However I see no reason at
all to deprecate a widely used function and create a myriad of BC issues
for no gain at all. Compatibility is a feature, and not only it is just
a feature - it's one of the most requested and most influential
features. BC breaks delay adoption of new versions by years, even for
minor things. For major widely used things
Please, when proposing removing something from PHP, check:
- If it is widely used
- If its removal gains huge benefit for PHP which can not be achieved
by any other way
If you answer yes on 1 or no on 2, then there's no point proposing this
removal. That would only make the next version unadoptable for a decade.
Remember, we still have people reluctant to move to 5.4, and you propose
to have them to rewrite all their code and wait until all their
libraries are rewritten (major cause of python 3 adoption problems is
libraries) for what exactly?
Yes, we can rewrite these functions in userland. So we can may others.
The long standing tradition of PHP in this area is to go the extra mile
for the user and actually provide helpful functions, even when
duplicating the functionality already available in user-land, for the
convenience of the user. But this is for adding things. For removing
things, bar is much, much higher.
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
Yes, we can rewrite these functions in userland. So we can may others.
The long standing tradition of PHP in this area is to go the extra mile
for the user and actually provide helpful functions
My point is that providing them as "userland implementation" even inside
core would be more interesting than having something magic going on under
the hood.
Yes, I realize that complete removal would completely kill PHP's adoption
for the next version, so I'm thinking about something like an ini setting:
"zeh_legacy_includeh = '/zeh/path/to/old/functions.php';"
Stupid idea?
Security implications?
And of course "yet another ini setting".
Yet this would allow removing a lot of internal functions that were written
just for the sake of it, and move them to something that can be maintained
by a larger userbase.
Marco Pivetta
Hi!
My point is that providing them as "userland implementation" even inside
core would be more interesting than having something magic going on
under the hood.
It certainly may be "interesting", and nobody prevents you from writing
a blog or implementing a library doing this. However, it is not the
reason to change the core functions of PHP.
Yes, I realize that complete removal would completely kill PHP's
adoption for the next version, so I'm thinking about something like an
ini setting:"zeh_legacy_includeh = '/zeh/path/to/old/functions.php';"
You're trying to solve a problem that did not exist before you tried to
solve it.
Yet this would allow removing a lot of internal functions that were
written just for the sake of it, and move them to something that can be
maintained by a larger userbase.
These functions weren't written "just for the sake of it". They were
written because people needed it.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
Hi!
My point is that providing them as "userland implementation" even inside
core would be more interesting than having something magic going on
under the hood.It certainly may be "interesting", and nobody prevents you from writing
a blog or implementing a library doing this. However, it is not the
reason to change the core functions of PHP.
It's not about "changing" them: from a consumer PoV, they'd still be
available.
Yes, I realize that complete removal would completely kill PHP's
adoption for the next version, so I'm thinking about something like an
ini setting:"zeh_legacy_includeh = '/zeh/path/to/old/functions.php';"
You're trying to solve a problem that did not exist before you tried to
solve it.
The problem always existed, and it's that it is very hard to escape from an
API that is dictated by the language itself.
Getting gradually rid of those APIs and making them swappable pieces simply
increases the degree of freedom that we get in our applications, by having
less people rely on stuff like array_map
and array_filter
(and the
funny parameter order), because PHP no longer has them under its protective
wing.
My suggestion for call_user_func
and related deprecation is just spawned
by some debugging raging, but the opportunity to kill a large chunk of the
shipped library stands.
Yet this would allow removing a lot of internal functions that were
written just for the sake of it, and move them to something that can be
maintained by a larger userbase.These functions weren't written "just for the sake of it". They were
written because people needed it.
Right, and now they can be built in a way that isn't coupled with the
engine itself.
Marco Pivetta
Hi!
The problem always existed, and it's that it is very hard to escape from
an API that is dictated by the language itself.
It is not a problem, at least not a define problem - what is "escape
from an API"? Why you would want to escape from the language you're
writing in?
Getting gradually rid of those APIs and making them swappable pieces
simply increases the degree of freedom that we get in our applications,
No, it does not. It increases the number of moving parts, makes the
environment more uncertain, requires more testing and potentially
fragments the ecosystem.
by having less people rely on stuff like
array_map
andarray_filter
Why would you want less people to use PHP features? More people should
be using array_map, not less.
Right, and now they can be built in a way that isn't coupled with the
engine itself.
It's not coupled with the engine, it's part of the PHP core functions
(which is separate part of PHP from the engine). And I still have to see
one reason why having them implemented in C is a problem. Without having
this reason, the discussion is pointless.
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
The problem always existed, and it's that it is very hard to escape from an
API that is dictated by the language itself.
Getting gradually rid of those APIs and making them swappable pieces simply
increases the degree of freedom that we get in our applications, by having
less people rely on stuff likearray_map
andarray_filter
(and the
funny parameter order), because PHP no longer has them under its protective
wing.
The existence of a highly performant, well tested, well documented
implementation of array_map in every copy of PHP is definitely a good
thing - it frees the programmer to think about their actual problem,
rather than such nuts and bolts. If it wasn't in the language, it would
be in standard frameworks, and a design mistake in those frameworks over
argument order would have created the same backwards compatibility
lock-in that we have today.
It may be that there are pieces of low-level functionality which could
be added, to make it easier to implement interesting tools for special
occasions; in that case, the conversation should not be about removing
existing tools which people are happily using.
--
Rowan Collins
[IMSoP]