On 23 October 2020 21:14:49 BST, Mike Schinkel <m...@newclarity.net> wrote:
>> On Oct 23, 2020, at 2:33 PM, Rowan Tommins <rowan.coll...@gmail.com>
>wrote:
>> 
>> I don't follow; is the resulting JSON different if you cast to
>object, or is there some other reason you prefer an object over using
>an associative array directly?
>
>The by-reference semantics of objects vs arrays in PHP.


*shrug* If you want things to be mutable between functions, stick an & in front 
of them; if you want copy-on-write performance, leave it to the engine. That 
doesn't seem to have anything to do with JSON or API as a use case.



>That pattern can have a non-insignificant performance penalty when
>dealing with a large number of objects, a use-case that is not
>infrequent when processing JSON, especially responses returned via an
>HTTP API.


That gives us all the more reason to look for efficient ways of populating 
anonymous class instances, then. (And, indeed, populating actual named classes, 
if such a penalty applies to them too.)

My point was that if we didn't already have it, making (object)$array create an 
instance of an anonymous class would feel natural and not lose anything that we 
have now.

I see stdClass as a badly named and no longer necessary kludge, and would 
rather see features that help replace it than features that rely on it.

Regards,

-- 
Rowan Tommins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to