Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63607 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71196 invoked from network); 23 Oct 2012 11:22:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2012 11:22:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.42 as permitted sender) X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.160.42 mail-pb0-f42.google.com Received: from [209.85.160.42] ([209.85.160.42:50813] helo=mail-pb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 56/98-06090-4ED76805 for ; Tue, 23 Oct 2012 07:22:14 -0400 Received: by mail-pb0-f42.google.com with SMTP id ro2so350111pbb.29 for ; Tue, 23 Oct 2012 04:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=guo4iBFXi7ucA7IOdk/PXsEHKhXsw5LevueD+1ff1AU=; b=vmAvi9ohevxcVlku22v6opIbWCsqvEF24iFkkcS//wdI0KTtYQExuUP8JYjRenpxzy X/qJsfvgI4jkCJiEZMpBqD7iDTW1/JQgFG9Zc8giKmCI2Spn1gvA4xAdlvAwMg/nWN64 Q/qLywqiKPEsAIl1oyWIBi4w+BvOaFJEdoBsWuWfrTufl72vCBQ9uYsnEuOLLmfKr5z2 Pvz2vBAVP86A2vv3fadIV7vH5jPelB1p2VFf9BdGfhDeUqPWSbvuDB4gByj9kv2X84Z5 YhQEuH1qkjYWKenwRYPFBDYKZeOCB/dQK9vWuNF9y1f4mf4KBSGzcKEvK/H5r026n+Xc zfBw== Received: by 10.66.73.6 with SMTP id h6mr34122963pav.69.1350991329573; Tue, 23 Oct 2012 04:22:09 -0700 (PDT) MIME-Version: 1.0 Sender: ekneuss@gmail.com Received: by 10.68.144.42 with HTTP; Tue, 23 Oct 2012 04:21:49 -0700 (PDT) In-Reply-To: References: <712F4499-949C-4C6F-A142-736A1B156189@gmail.com> <5084281C.9020507@sugarcrm.com> Date: Tue, 23 Oct 2012 13:21:49 +0200 X-Google-Sender-Auth: h3uicsFEe6N_1KZMZkXh2QjkwWQ Message-ID: To: Levi Morrison Cc: Anthony Ferrara , Stas Malyshev , Nikita , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Generics proposal From: colder@php.net (Etienne Kneuss) Hi, On Tue, Oct 23, 2012 at 4:17 AM, Levi Morrison wrote: >>> Especially if the ability was afforded to arrays as well (function >>> foo(array $array){})... >> >> This would require O(n) runtime tests, I would definitely not go there. > > Actually, it does not require O(n) runtime tests. The solution is > simple: store the type when it is created. Whenever an element is > added, make sure it matches the correct type. All this does is add > some flat overhead. If you test every time you add one element, that's still O(n) tests where n is the size of the array, the only benefit is that it is not checked for each calls to a function. But now we are talking about attaching non-trivial types to variables, and non-trivial checks in a lot of places (think references etc..), let's not go there... > > I am also supportive of the idea of having generics, but I am not sure > that the work it would take is worth it. -- Etienne Kneuss http://www.colder.ch