Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63754 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75839 invoked from network); 6 Nov 2012 03:14:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Nov 2012 03:14:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.223.170 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.223.170 mail-ie0-f170.google.com Received: from [209.85.223.170] ([209.85.223.170:59189] helo=mail-ie0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DF/31-59729-59088905 for ; Mon, 05 Nov 2012 22:14:30 -0500 Received: by mail-ie0-f170.google.com with SMTP id c12so10642855ieb.29 for ; Mon, 05 Nov 2012 19:14:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:x-originating-ip:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=UkKX6XzfutMwCQeHfIRTpNZyVW5WkJTLE21KDamr+90=; b=pqR8dfmHtRq9vHX3iRoMsfG/zS6cI6h7pOSODfGojfN7sh4C8Lp6J4aZRd0GbNBQpV 6QRiKrEGmVl0c1vg6fzIBxncZWgwPfeaWL0b7J+RAPYw5cAONDevegIXcC4g7+AsL6uQ fivISgKJSTqYYa3uO/Tedcv8AEbL7IeGMCEBRfS6LRtkal7637MEdr0bysRWWTpPoGFI a6x7bVzqrFntT5rlLsM6AyZkbk8as2n3S3iR/pdzS+N/v4mUXHJc4wVrQ3mMvMurntDq 3PJA/uUTzyz+nyIxMo3UO9/hDKeOesJJk4dJ5vGI8S8KQLgP5DCQqVGjQkMwcSV+J4RG ZAxA== MIME-Version: 1.0 Received: by 10.50.222.226 with SMTP id qp2mr11491030igc.74.1352171666504; Mon, 05 Nov 2012 19:14:26 -0800 (PST) Sender: php@golemon.com Received: by 10.64.21.193 with HTTP; Mon, 5 Nov 2012 19:14:26 -0800 (PST) X-Originating-IP: [98.210.180.187] In-Reply-To: References: <712F4499-949C-4C6F-A142-736A1B156189@gmail.com> <5084281C.9020507@sugarcrm.com> Date: Mon, 5 Nov 2012 19:14:26 -0800 X-Google-Sender-Auth: 6MHnI8ykJWqiob8vn7CEG8msaHg Message-ID: To: Etienne Kneuss Cc: Levi Morrison , Anthony Ferrara , Stas Malyshev , Nikita , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQmQWg8IvNaq9xNAmMtb3t+L7e66qM6kLxUAEnrn97iA0xmuH2Pu5cQpz8hUoVPFg5mUqv+d Subject: Re: [PHP-DEV] Generics proposal From: pollita@php.net (Sara Golemon) Sorry to be late to the conversation, but fwiw, HipHop is adding Generics (and some other cool things) to our PHP implementation. We plan to provide a PHP equivalent implementation in the form of a pre-processor extension which can live in PECL. The implementation would of course be cleaner if done directly in the engine, but with APC the performance hit of doing an extra transformation pass should disappear. Hopefully this satisfies both the want for Java/C++-like syntax without "polluting" the language. -Sara On Tue, Oct 23, 2012 at 4:21 AM, Etienne Kneuss wrote: > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >