Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71362 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52440 invoked from network); 20 Jan 2014 22:00:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2014 22:00:23 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.107 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.107 smtp107.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.107] ([108.166.43.107:44282] helo=smtp107.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/CD-02192-57C9DD25 for ; Mon, 20 Jan 2014 17:00:22 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp6.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 9D426981A0; Mon, 20 Jan 2014 17:00:19 -0500 (EST) X-Virus-Scanned: OK Received: by smtp6.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 2732D98134; Mon, 20 Jan 2014 17:00:19 -0500 (EST) Message-ID: <52DD9C72.9070409@sugarcrm.com> Date: Mon, 20 Jan 2014 14:00:18 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Sara Golemon CC: Philip Sturgeon , "internals@lists.php.net" References: <20140116110127.202079vzjsj76n7b@webmail.tutteli.ch> <0B.B1.24763.139B7D25@pb1.pair.com> <002001cf12da$2bfbda90$83f38fb0$@tutteli.ch> <52DCA3E7.80602@lerdorf.com> <52DCED71.3020207@pthreads.org> <006301cf15f5$22f8df60$68ea9e20$@tutteli.ch> <52DD90E5.2030205@sugarcrm.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Introducing "Array Of" RFC From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > private $spanners = []; > public function __offsetset($key, $value) { if (!($value instanceof > Spanner)) throw new Exception("F-off"); $this->spanners[] = $value; } Right! So I don't see anything wrong with that. I'd be even OK with: public function __offsetset($key, Spanner $value) { $this->spanners[$key] = $value; } And that IMO covers 90% of use cases for Spanners[]. But, thinking more about it, if I *had* to choose between the two with no other options, I'd probably be happier with ArrayOf (provided that actually means just a generated class ArrayOf$Spanner and not checking every element of the actual array). Though IMO even this case if handled by one line of code, but at least here I can see *some* use case (namely, code generation if you have thousands of ArrayOf things and you *really* need to typecheck each and every one of them). Whether we need it or not is a bit of broader discussion - which I am leaning to "not" but we could argue about it. But at least it feels for me more "natural" - you just generate a bunch of code (there are a number of cans on worms in it but I ignore it for now). Checking each element post-factum just feels wrong way to approach it. It's like taking you car to a mechanic each time you'd like to drive somewhere (yes, car analogy, I live in America, what do you expect?) -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227