Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112112 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59081 invoked from network); 23 Oct 2020 21:35:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Oct 2020 21:35:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 320061804AA for ; Fri, 23 Oct 2020 13:53:30 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,MISSING_HEADERS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 23 Oct 2020 13:53:29 -0700 (PDT) Received: by mail-wm1-f52.google.com with SMTP id c16so3518667wmd.2 for ; Fri, 23 Oct 2020 13:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:cc:from:message-id; bh=GuU2aTa+71H93HuL7nAS1CwV3IN8ll1UapTAwplSVtI=; b=MTSi8oddg9jPzxzl1e3hzbJ+TB+dKHpQDwssYstxqULwkMNhmPn+nsURmTyui+uqL+ k8lZrs3FQlov3+BfhJAZ6/ccAtc/iLjLNDwLIwDoJfjEtHRTTjaCRRyXwtMFeDkp/7zO tcwUpWmz0EYekJpfNpztB8jd7Lilfx7eYa93J+RR8mwK8VK6kdDGi/Ih/XnJ8mhjCRaz aL3EQYhNVbuHU5wTj+MofqYZtmUawDNG9P3pnMdhEsILD4EZmhf/s2hIMsvUbjeqmMR7 9wrbpYTxZXWvHcl7nqjGEC5zdU/tkF2E5nphEpFYurer09mgITkUIa2oAne4vcQArny1 YRAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:cc:from:message-id; bh=GuU2aTa+71H93HuL7nAS1CwV3IN8ll1UapTAwplSVtI=; b=qSZok8ar1wRUzjMbjZITYOC5ActPyMRcG3xkbK7WOUmZrccOpAD2gBSbD1932FSotw Xzezu8Jp1+XGiMpHiJaf2OFWpfde2potPrLDvXVJkpONcU2fABBdqKVSc9mnXhnzhqSo xtl0j/G40fwzk4fijWkz++naZ7Pgx8OQENwG3p4H8ixgCiB1dNB+oPKjjPyNoFK6ugmU k6WvU6AHEa35AE5nWfP8Gk9HDDD2ZLQSBWsvMc3GS1KKg9nEFR3m0GYhP0640iLobl45 QT/Rwkw7fcUs7vVx/9wscpCjSWuHo/ElThcU8HCSUyMmxIOwN5XYBC9EYCVNQelE4gip 7rYw== X-Gm-Message-State: AOAM531sY70e3cCznT915bnJYNLDJb3PqNfSLMI70jIf53JA9qy429sf jz5bYlLpi8XUw/w6YdUkrDJgNgomPmI= X-Google-Smtp-Source: ABdhPJwASfa2XDs2PjVkpYTneAvWeeuiTQWPSYgCSGnf8zRABm2o6Ixy2/2+fTUpZOx66SeYOR0XkQ== X-Received: by 2002:a1c:9a4b:: with SMTP id c72mr3925125wme.157.1603486405752; Fri, 23 Oct 2020 13:53:25 -0700 (PDT) Received: from [192.168.0.12] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.gmail.com with ESMTPSA id r128sm5708116wma.20.2020.10.23.13.53.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Oct 2020 13:53:24 -0700 (PDT) Date: Fri, 23 Oct 2020 21:53:23 +0100 User-Agent: K-9 Mail for Android In-Reply-To: <2A808AB8-7179-41F6-88F4-A19C8F7FA171@newclarity.net> References: <5f92f1e0.1c69fb81.a800f.cbe1SMTPIN_ADDED_MISSING@mx.google.com> <2A808AB8-7179-41F6-88F4-A19C8F7FA171@newclarity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable CC: internals@lists.php.net Message-ID: <02DD5C20-522B-46C7-B5EE-BC61E2EC4C6F@gmail.com> Subject: Re: [PHP-DEV] Is there any interest for object constructor shorthand *just forstdClass* From: rowan.collins@gmail.com (Rowan Tommins) On 23 October 2020 21:14:49 BST, Mike Schinkel wrot= e: >> On Oct 23, 2020, at 2:33 PM, Rowan Tommins >wrote: >>=20 >> 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=2E *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 engin= e=2E That doesn't seem to have anything to do with JSON or API as a use cas= e=2E >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=2E That gives us all the more reason to look for efficient ways of populating= anonymous class instances, then=2E (And, indeed, populating actual named c= lasses, if such a penalty applies to them too=2E) My point was that if we didn't already have it, making (object)$array crea= te an instance of an anonymous class would feel natural and not lose anythi= ng that we have now=2E 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=2E Regards, --=20 Rowan Tommins [IMSoP]