Re: [STANDARDS] FR question: unset() and reset()

[email protected] (Chris Wright)
Newsgroups php.standards
Message-ID <CAGAGxba9TzUt55sk8H-4+jNiYNw3VB3+EnR-GuFusxpdxTkwjA@mail.gmail.com>
On 4 June 2015 at 10:49, Rasmus Malver <[email protected]> wrote:

> Hello standardisers,
>
> When processing JSON data from an external API, it can be necessary to
> reset() and advance multiple arrays at the same time.
>
> Unset takes unlimited variables as arguments, but resetting and all array
> movement (next, prev, end, etc.) takes only one.
>
>         unset($a, $b, $c);
>         # vs.
>         reset($a);
>         reset($b);
>         reset($c);
>
> However the array functions provide a return value, and the sort array
> functions take flags, which is presumably why this group has been
> harmonised to only take a single argument.
>
> I cannot find this topic in the back catalogue. Has it been considered?
> Does it have legs to allow multiple arguments in the flag-less array
> functions?
>

It's probably not a good idea to do this. In the specific example given,
reset() might one day need to take other arguments that describe the
desired behaviour (for example, it might be adapted to give some seeking
behaviour, where the array pointer can be set to a specific position other
than simply "the beginning").

Generally one would implement shorthand helpers like this in userland, e.g.
http://3v4l.org/t0PoN#v560

The issue is less to do with consistency and more to do with the need to
draw a line somewhere. We cannot provide a specific function for everyone's
use case, we provide the building blocks to create these higher-level
routines yourself.

Thanks, Chris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.