Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71357 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43244 invoked from network); 20 Jan 2014 21:19:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2014 21:19:17 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.220.44 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.220.44 mail-pa0-f44.google.com Received: from [209.85.220.44] ([209.85.220.44:48272] helo=mail-pa0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/EB-02192-4D29DD25 for ; Mon, 20 Jan 2014 16:19:16 -0500 Received: by mail-pa0-f44.google.com with SMTP id kq14so7487361pab.17 for ; Mon, 20 Jan 2014 13:19:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=FRQNMNsn7X/VXKxVuBPlsPmZ1BRM4IyQAjLSWJU/DK0=; b=Ktw2aMq5KfUDz7Y5nHzzFsQCbf9VP+wyyLIM8Ew3H27/+ncQY6tlX471uWRKuQI66X aEC9nPFC4bdoYxkWV2aGnVNTNrIlNSkKNHMNg7Se4pHIjeUZCZLwqwnq8GMT97g6FriF E3FIubpl/KVVcBaWOWVhNCXlnfZat7YDjTBYePIYK2GZ+QxYy8mVn5ca8n/d4LkAEUGA w5WMKzV+QPMcmn69H770cGyTOhfZjAPmRDPh9Unh2vjK7I+59xjlJdGLqyJa1Hs0nfKG Zm5wsiYlket8D+JkgG5qv1gyJwgK6GswOGVqVKEPu+IBXLHkBlAH3k/TC5UEemH3Iqsk CjNw== X-Gm-Message-State: ALoCoQk8FDXaO2QPMvO3mONtr6zyEdR9JSShtnjnCCzpsTCQYfsdruY72ejWBdo6PiBYUXz7T9cH MIME-Version: 1.0 X-Received: by 10.68.180.37 with SMTP id dl5mr20563920pbc.111.1390252753523; Mon, 20 Jan 2014 13:19:13 -0800 (PST) Sender: php@golemon.com Received: by 10.70.77.164 with HTTP; Mon, 20 Jan 2014 13:19:13 -0800 (PST) X-Originating-IP: [2001:470:1f09:2fa:22c9:d0ff:fe87:295b] In-Reply-To: <52DD90E5.2030205@sugarcrm.com> References: <52D71748.1090402@googlemail.com> <52D71FAE.8030002@ajf.me> <005001cf124f$3a40df00$aec29d00$@tutteli.ch> <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> Date: Mon, 20 Jan 2014 13:19:13 -0800 X-Google-Sender-Auth: rWKmWEw7J9nZBpZPWjCcSRsoswA Message-ID: To: Stas Malyshev Cc: Philip Sturgeon , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Introducing "Array Of" RFC From: pollita@php.net (Sara Golemon) > Note that neither generics nor array strict typing gives you that. > Neither of them can control what is being put into the bag. The only > thing you can do is to look in the bag and reject what has been put > there post-factum (actually, with generics you can't do even that - > generics parametrize you types, but you still have to have the > typechecks somewhere, so from type checking point generics change > nothing) - i.e. the check happens not when something is put in the bag > but when you get the bag and you have to examine that bag (every single > time you touch it) and pull out each element of it and ensure it is > still a spanner. If you put the bag down, next time you touch it you > have to pull out every single thing out of the bag and check if it is a > spanner *again*. Is it really the bag you want to deal with? I wouldn't > really want to own such bag, I'm not OCD enough for that :) > Well, arrayof using generics-like syntax doesn't give you entrance type checking, but actual generics would. Or, to map it into current PHP terms: private $spanners = []; public function __offsetset($key, $value) { if (!($value instanceof Spanner)) throw new Exception("F-off"); $this->spanners[] = $value; } But this RFC isn't about generics, it's about arrayof typehinting and ways to make that work for PHP. Your point about perf is absolutely valid and one which I'd still like to hear addressed. -Sara