On Mon, 14 Jan 2019 at 15:00, Nikita Popov <nikita....@gmail.com> wrote:

> The way I see it, stdClass is basically an array in object notation (and
> object passing semantics). It carries data in the form of key value pairs
> and has no associated logic. The only things you can do with it are access
> keys (properties) and ... iterate over them.
>
> [...] But now that we do have it, and with the way it is typically being
> used, I think it's fully appropriate to iterate over it.
>


I think it's the assumption about "the way it is typically being used"
where I differ from you. I generally see stdClass being used where people
want to access specific keys using -> notation, and maybe to get the
pass-by-pointer semantics. I'm not convinced that iterating over it as an
ordered collection is a sufficiently universal use case that it should be
an exception to the proposed rule of "objects aren't iterable unless
iteration logic has been defined".

I can see it might be convenient occasionally, but it feels like an
unnecessary special case, on top of a feature which I agree should be
discouraged anyway.

Regards,
-- 
Rowan Collins
[IMSoP]

Reply via email to