Hi internals,
I'd like to deprecate function: sizeof()
[1][2], which is an alias of
count()
. some people
expect it return the memory size of the variable.
The doc page's[1] user contributed notes indicate that too.
What do you think?
[1] http://php.net/sizeof
[2] https://github.com/php/php-src/pull/1161
[3] http://stackoverflow.com/questions/3974385/php-array-count-or-sizeof
--
Reeze Xia
http://reeze.cn
Hi
2015-03-07 16:51 GMT+01:00 reeze reeze@php.net:
Hi internals,
I'd like to deprecate function:
sizeof()
[1][2], which is an alias of
count()
. some people
expect it return the memory size of the variable.The doc page's[1] user contributed notes indicate that too.
What do you think?
'm a big -1 on this, while I know it returns the memory size in a C
perspective, I think it makes perfect sense to remain an alias, it
would break lots of applications for a very tiny to nothing gain.
--
regards,
Kalle Sommer Nielsen
kalle@php.net
Hi,
2015-03-07 17:41 GMT+01:00 Kalle Sommer Nielsen kalle@php.net:
I'm a big -1 on this, while I know it returns the memory size in a C
perspective, I think it makes perfect sense to remain an alias, it
would break lots of applications for a very tiny to nothing gain.
I don't think the alias make sense and is really misleading and I've
seen sizeof("abc"); often enough (Don't get me wrong that's equally
bad with count, but sizeof encourages that usage, imo).
Having two functions that do exactly the same using different names
for no good reason (one of them referring to a different operation in
a more popular language) isn't optimal. Code using a deprecated sizeof
call is trivial to fix.
But:.
I'm not sure if the cost involved is really worth it, after all some
big projects enforce sizeof over count and github returns over 1.2m
results for sizeof+php (many false positives from html files
documenting c code etc., still a huge number) .
Random first two projects with over 500 stars/or big installation base I found:
http://area51.phpbb.com/docs/31x/coding-guidelines.html#general :
"Use sizeof instead of count"
https://github.com/atoum/atoum/blob/master/CC.md#arrays :
"To get length of an array, use sizeof instead of count (no technical
reason about that, it's just the current convention)".
On the other side: Removal of sizeof is doable with a patch release
for almost all projects and shouldn't really require more than 5 to 10
minutes (+ time to review the diff) for most projects.
On the other side: Removal of sizeof is doable with a patch release
for almost all projects and shouldn't really require more than 5 to 10
minutes (+ time to review the diff) for most projects.
If taken in conjunction with tidying up the IEEE C standard consistency
then dropping what is basically the wrong use of sizeof makes a lot of
sense? Eventually using sizeof for the physical size of elements in line
with it's C use would be more consistent.
--
Lester Caine - G8HFL
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
Hi
2015-03-07 18:35 GMT+01:00 Sebastian B.-Hagensen sbj.ml.read@gmail.com:
Hi,
I don't think the alias make sense and is really misleading and I've
seen sizeof("abc"); often enough (Don't get me wrong that's equally
bad with count, but sizeof encourages that usage, imo).
Having two functions that do exactly the same using different names
for no good reason (one of them referring to a different operation in
a more popular language) isn't optimal. Code using a deprecated sizeof
call is trivial to fix.
Well we could make count()
/sizeof() work for strings, so that if:
C:> php -r "echo sizeof('abc');"
3
although it would not really accomplish much imo., I think it is more
of what background you come from that makes the most sense to me, I
got into PHP before C and I enjoy sizeof more for array sizes than
count, but that is just a pure preference.
--
regards,
Kalle Sommer Nielsen
kalle@php.net
Hi
Well we could make
count()
/sizeof() work for strings, so that if:
C:> php -r "echo sizeof('abc');"
3although it would not really accomplish much imo., I think it is more
of what background you come from that makes the most sense to me, I
got into PHP before C and I enjoy sizeof more for array sizes than
count, but that is just a pure preference.
Maybe count()
and sizeof()
should retain original functionality for the
sake of compatibility, but should emit warning if used on non-array/object
variables?
This seems like a gentle way to steer users towards using strlen()
on
strings.
Using sizeof(null) seems somewhat legitimate, but sizeof("asdf") seems like
a newbie mistake at counting characters in a string.
b.
PS: All above assumes the functionality of sizeof()
does not change. If
sizeof()
functionality should be changed to be more aligned with it's C
counterpart, then above argument does not stand.
Hi,
Hi
2015-03-07 16:51 GMT+01:00 reeze reeze@php.net:
Hi internals,
I'd like to deprecate function:
sizeof()
[1][2], which is an alias of
count()
. some people
expect it return the memory size of the variable.The doc page's[1] user contributed notes indicate that too.
What do you think?
'm a big -1 on this, while I know it returns the memory size in a C
perspective, I think it makes perfect sense to remain an alias, it
would break lots of applications for a very tiny to nothing gain.
It is a deprecated warning I won't break code I think.
This could makes those project more maintainable (new PHP programmer could
be easier to maintain the code without surprise), and it will be trivial to
fix this. We could move things forward ;-)
--
regards,Kalle Sommer Nielsen
kalle@php.net
--
Reeze Xia
http://reeze.cn
Hi Reeze,
It is a deprecated warning I won't break code I think.
This could makes those project more maintainable (new PHP programmer could
be easier to maintain the code without surprise), and it will be trivial to
fix this. We could move things forward ;-)
It's possible option for confusing APIs.
If sizeof()
is kept at least until PHP8 or PHP9, I'll vote yes for this.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
Hey:
Hi Reeze,
It is a deprecated warning I won't break code I think.
This could makes those project more maintainable (new PHP programmer could
be easier to maintain the code without surprise), and it will be trivial to
fix this. We could move things forward ;-)It's possible option for confusing APIs.
Ifsizeof()
is kept at least until PHP8 or PHP9, I'll vote yes for this.
We just removed all DEPRECATED functions...
then you want to brings new :<
anyway, I'd prefer don't do it. especially with little gain.
thanks
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
--
Xinchen Hui
@Laruence
http://www.laruence.com/
Hey:
Hi Reeze,
It is a deprecated warning I won't break code I think.
This could makes those project more maintainable (new PHP programmer could
be easier to maintain the code without surprise), and it will be trivial to
fix this. We could move things forward ;-)It's possible option for confusing APIs.
Ifsizeof()
is kept at least until PHP8 or PHP9, I'll vote yes for this.
We just removed all DEPRECATED functions...
we did not remove functions as far as I can tell. Some extension at best.
then you want to brings new :<
anyway, I'd prefer don't do it. especially with little gain.
Agreed
And generally speaking, we should really think again about this flag,
it has been proven to be a mess at best, or useless at worst.
--
Pierre
@pierrejoye | http://www.libgd.org
Hi Pierre and all,
Hey:
On Tue, Mar 10, 2015 at 10:07 AM, Yasuo Ohgaki yohgaki@ohgaki.net
wrote:Hi Reeze,
It is a deprecated warning I won't break code I think.
This could makes those project more maintainable (new PHP programmer
could
be easier to maintain the code without surprise), and it will be
trivial to
fix this. We could move things forward ;-)It's possible option for confusing APIs.
Ifsizeof()
is kept at least until PHP8 or PHP9, I'll vote yes for this.
We just removed all DEPRECATED functions...we did not remove functions as far as I can tell. Some extension at best.
then you want to brings new :<
anyway, I'd prefer don't do it. especially with little gain.
Agreed
And generally speaking, we should really think again about this flag,
it has been proven to be a mess at best, or useless at worst.
There are 2 camps, people who would like to keep procedural API as it is
and people who would like to improve/maintain procedural API while there
are no separated camps having improved/maintained OO API.
It may be time to discuss how we are going to use namespace for internal
functions/classes/interfaces to move forward both procedural and OO APIs
so that we'll have zero BC API upgrade.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
Hi Pierre and all,
On Tue, Mar 10, 2015 at 11:59 AM, Pierre Joye pierre.php@gmail.com
wrote:Hey:
On Tue, Mar 10, 2015 at 10:07 AM, Yasuo Ohgaki yohgaki@ohgaki.net
wrote:Hi Reeze,
It is a deprecated warning I won't break code I think.
This could makes those project more maintainable (new PHP programmer
could
be easier to maintain the code without surprise), and it will be
trivial to
fix this. We could move things forward ;-)It's possible option for confusing APIs.
Ifsizeof()
is kept at least until PHP8 or PHP9, I'll vote yes for
this.
We just removed all DEPRECATED functions...we did not remove functions as far as I can tell. Some extension at best.
then you want to brings new :<
anyway, I'd prefer don't do it. especially with little gain.
Agreed
And generally speaking, we should really think again about this flag,
it has been proven to be a mess at best, or useless at worst.There are 2 camps, people who would like to keep procedural API as it is
and people who would like to improve/maintain procedural API while there
are no separated camps having improved/maintained OO API.It may be time to discuss how we are going to use namespace for internal
functions/classes/interfaces to move forward both procedural and OO APIs
so that we'll have zero BC API upgrade.
I do not think it has anything to do with OO or procedural but the actual
gains.
I see none here.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
Hi Pierre,
I do not think it has anything to do with OO or procedural but the actual
gains.I see none here.
Why not?
PHP is distributed with set of APIs. i.e. Libraries.
Tight binding with libraries and language make library update difficult .
Besides zero BC, it seems it's time to introduce namespaces for internal
features.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
Hi!
I'd like to deprecate function:
sizeof()
[1][2], which is an alias of
count()
. some people
expect it return the memory size of the variable.
Why? So, some people are wrong, why we need to mess with the language to
accommodate them?
I don't think it is a good idea.
--
Stas Malyshev
smalyshev@gmail.com
Hi all,
On Sun, Mar 8, 2015 at 5:41 AM, Stanislav Malyshev smalyshev@gmail.com
wrote:
I'd like to deprecate function:
sizeof()
[1][2], which is an alias of
count()
. some people
expect it return the memory size of the variable.Why? So, some people are wrong, why we need to mess with the language to
accommodate them?
I don't think it is a good idea.
The same opinion. Unless there are good enough reasons, these aliases
should be kept. If "Consistent function names" RFC passes, aliases will be
listed in main function page only. It may reduce confusions hopefully.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
Hi all,
On Sun, Mar 8, 2015 at 5:41 AM, Stanislav Malyshev smalyshev@gmail.com
wrote:I'd like to deprecate function:
sizeof()
[1][2], which is an alias of
count()
. some people
expect it return the memory size of the variable.Why? So, some people are wrong, why we need to mess with the language to
accommodate them?
I don't think it is a good idea.The same opinion. Unless there are good enough reasons, these aliases
should be kept. If "Consistent function names" RFC passes, aliases will be
Yes, I think so, it didn't remove the alias, but propose use use count()
instead.
listed in main function page only. It may reduce confusions hopefully.
That might helps.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
--
Reeze Xia
http://reeze.cn
Hi internals,
I'd like to deprecate function:
sizeof()
[1][2], which is an alias of
count()
. some people
expect it return the memory size of the variable.The doc page's[1] user contributed notes indicate that too.
What do you think?
As I tend to like the idea to cleanup things, adding warning and
deprecation warnings for the sake of it is not too appealing to me.
Especially for this kind of things.
Cheers,
Pierre
@pierrejoye | http://www.libgd.org
Hi internals,
I'd like to deprecate function:
sizeof()
[1][2], which is an alias of
count()
. some people
expect it return the memory size of the variable.The doc page's[1] user contributed notes indicate that too.
What do you think?
As I tend to like the idea to cleanup things, adding warning and
deprecation warnings for the sake of it is not too appealing to me.
Especially for this kind of things.
Yes it will not really fix the confusion, and it is a small problem,
I know few decent projects use sizeof, we could make the old code involve
and more consist.
sizeof()
was kept because of BC since PHP4.0, count()
should be the
recommended function.
Cheers,
Pierre
@pierrejoye | http://www.libgd.org
--
Reeze Xia
http://reeze.cn