Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91226 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73805 invoked from network); 12 Feb 2016 16:16:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Feb 2016 16:16:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.43 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.43 mail-wm0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:36484] helo=mail-wm0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B6/21-00989-0650EB65 for ; Fri, 12 Feb 2016 11:16:33 -0500 Received: by mail-wm0-f43.google.com with SMTP id p63so27702797wmp.1 for ; Fri, 12 Feb 2016 08:16:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:cc:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=J5TsDZhmNlkKPlG9Jk6sdPGGqwu+fYXvdJWAfGjhH/Y=; b=Wru3RK8EswZmFJ1BzTzOmtNTkwfkHu8xtNfggpjE7uZnv+NiY9K084oYAUfK9urA/x S5LiGJdCWfq4vtvFVbqmHpyb8MHrG3Q4qnXN8Ol1dnrkNcwzG2tzsoJHAoU7pws2ubdX 6aAIL4wQJGqXF30hle8BN1F//r78/NoTfBmTMX9UvVpyhtVBiyxQUGUS5jaBWGvnNkfJ hnZ0G0kDUPrfxh0RzlawUGzzYRqJpteCw2AWK69ntSr9xI3FBUpGvfoWIpq6FQCJoMub wZUWwGu2z2h+1/3oxWoZIPLQuw88FQbElqew5hFlTWy0/WbtudDsP4xd+bRQEAgRBXkY 7shQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:cc:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=J5TsDZhmNlkKPlG9Jk6sdPGGqwu+fYXvdJWAfGjhH/Y=; b=XDzjiaItUu4ulKhz8MTD9jXMyBMJpb6kuDH+S4DQxr90dIf2cPfd38QGvG5MesG9Wu kf0QEI6HMIlQUhLbgbXmBQ8KBL85pi4b1cNWRvcy/l2xie3mAN2Z2J/d18MCAHa4YamL iJlALih6n6mb5XSf4y8iMEipARdOWvZA42pOOSF82Ew/OMB8CxmZvaJdJ+DhqxFvQ+X9 zKbw4XdAAy2/soNfZ8qLRVhv6QeWLi4WyiKgycU+OMeMEynf7QSsnZUS8qhXnckEng6Z x8jXBawhzNx4iF87DwOre/Y/irXiGBmMQ4wbbqnwJMxE1FmU5BBddV7yTGOwr9oLI+xF 1QyA== X-Gm-Message-State: AG10YOTLqlgsJrhGvkpIcQoOPkCSrYll1IaU9aAP63uFTHNG/So2lInJnWmXbTBLrTah3Q== X-Received: by 10.194.77.235 with SMTP id v11mr2571200wjw.3.1455293789795; Fri, 12 Feb 2016 08:16:29 -0800 (PST) Received: from [192.168.0.152] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id s2sm12701000wjs.39.2016.02.12.08.16.28 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 12 Feb 2016 08:16:29 -0800 (PST) To: internals References: <38.31.07203.2EB94B65@pb1.pair.com> <8E.1A.36326.338F8B65@pb1.pair.com> <56BDEBC8.4090806@gmail.com> <56BDF26B.8030301@gmail.com> <56BDF6FC.1020309@gmail.com> Cc: "S.A.N" Message-ID: <56BE04F2.6050603@gmail.com> Date: Fri, 12 Feb 2016 16:14:42 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][VOTE] Allow specifying keys in list() From: rowan.collins@gmail.com (Rowan Collins) S.A.N wrote on 12/02/2016 15:21: > It's not just a matter of taste, the object is always passed by > reference, an array is copied when you change, object literal syntax > like JSON, sorely lacking in PHP. Objects are passed by *pointer*, because they're expected to have methods that mutate their state in place. An object with arbitrary keys is unlikely to have any such methods, so I still don't really see the point: if you want to manipulate an array in place, put an & in your function signature. If you actually want an object that contains arbitrary data, just have a single property called $data with the array in; that way, you can have "real" (declared) properties alongside, e.g. class CacheItem { private $data = []; private $last_updated; public function __construct($data) { $this->data = $data; $this->last_updated = time(); } } You could even implement __get and __set so that the keys of $data were exposed as though they were public properties. stdClass has always seemed completely pointless to me, because it doesn't provide any encapsulation, and making a "real" object (i.e. a declared class, with declared properties) is so easy, and so much more powerful. That's why I call it a matter of taste: if I want a hash, I'll use an array, which is already full-featured; if I want an object, I'll define a class for it and use at least some OO principles. Regards, -- Rowan Collins [IMSoP]