Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63606 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38789 invoked from network); 23 Oct 2012 02:17:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2012 02:17:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:34001] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 51/95-06090-32EF5805 for ; Mon, 22 Oct 2012 22:17:08 -0400 Received: by mail-lb0-f170.google.com with SMTP id gm13so61240lbb.29 for ; Mon, 22 Oct 2012 19:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=3TIwyytzTdwW9BeIvSB58iM5KMVhnCkTpfEhLbbJdYc=; b=H9/wrG4QNcC6D4FitMNz3lceSqLKD9DehrsD7nV+ZtAZkmG+FUWk+CQB6JCwVQxouM ssIK1H9krr+q3JbkofiSV98cq1VBRXB/Lk57VQBg7QVcTqeeaTKjFB3ZdtbksauYjySm paX+IdV/RtBU34bByPFY1E9PqZHeOwji4XRFG989g2MMlS4aK9r2PE7JIIV+9lypNIW1 6jj9yqei0WmYKG24Qh3o/tysWXalMM4dNUbNnIfpSNV5VdeVmW4qmXl4X+dwseB4kG7t /mMmEMfz8cttCUeWcD1gwsXEvMbdgjhf4Tg5rFIx5G/XgZt5fP/d/pNTFi0nVMR8+cex fxYg== MIME-Version: 1.0 Received: by 10.152.47.112 with SMTP id c16mr9977230lan.50.1350958623667; Mon, 22 Oct 2012 19:17:03 -0700 (PDT) Received: by 10.112.36.39 with HTTP; Mon, 22 Oct 2012 19:17:03 -0700 (PDT) In-Reply-To: References: <712F4499-949C-4C6F-A142-736A1B156189@gmail.com> <5084281C.9020507@sugarcrm.com> Date: Mon, 22 Oct 2012 20:17:03 -0600 Message-ID: To: Etienne Kneuss Cc: Anthony Ferrara , Stas Malyshev , Nikita , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Generics proposal From: morrison.levi@gmail.com (Levi Morrison) >> 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. I am also supportive of the idea of having generics, but I am not sure that the work it would take is worth it.