Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88059 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56265 invoked from network); 5 Sep 2015 19:48:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Sep 2015 19:48:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=john.lesueur@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=john.lesueur@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.178 as permitted sender) X-PHP-List-Original-Sender: john.lesueur@gmail.com X-Host-Fingerprint: 209.85.213.178 mail-ig0-f178.google.com Received: from [209.85.213.178] ([209.85.213.178:35114] helo=mail-ig0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9E/6E-49334-6274BE55 for ; Sat, 05 Sep 2015 15:48:54 -0400 Received: by igbkq10 with SMTP id kq10so32641031igb.0 for ; Sat, 05 Sep 2015 12:48:51 -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=WQ8crXtkFMiBcLV2iahPLcAn5o1R+fgNvSRd7ZFLZZ8=; b=cbz2hxE7Wj2bfVOAvxsjaWrZdt9yANAZDmq9142ZIOxC35rweY5FqC0V7LGF9l2CNC tSswOiF8E42tp7LIukgu1WSrWgFvBBRi0yim5QgIDUw8ihStR3WKPgT70ai5BB4qGJyS 7bvJI8Fos/dc0l/C4bfUFCO66pDjTYQG1tOXD56dnBqOvbz1KgiIFTzVxVllG9O3CuU+ PQ4Tc0EIsJ9bbuqBhSrAb+x/FJ3UTdKC9tw/dVHG+5Wgj0dNQswIl78Ed0zQMx1aKaL/ ro6v0j6sTFdN1WZQu4kzsvAUIKb1aAMCLTDbgGvFilJqLNkpGAeFIP/wa0EBpXw8+56V gmew== MIME-Version: 1.0 X-Received: by 10.50.13.10 with SMTP id d10mr19850918igc.20.1441482531113; Sat, 05 Sep 2015 12:48:51 -0700 (PDT) Received: by 10.107.182.135 with HTTP; Sat, 5 Sep 2015 12:48:51 -0700 (PDT) In-Reply-To: References: <55E4B9AA.9060906@dasprids.de> Date: Sat, 5 Sep 2015 13:48:51 -0600 Message-ID: To: =?UTF-8?Q?Pavel_Kou=C5=99il?= Cc: "Ben Scholzen 'DASPRiD'" , PHP internals Content-Type: multipart/alternative; boundary=089e0118487437910c051f054e50 Subject: Re: [PHP-DEV] Generic classes and methods RFC From: john.lesueur@gmail.com (John LeSueur) --089e0118487437910c051f054e50 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Sep 1, 2015 at 2:54 AM, Pavel Kou=C5=99il wrot= e: > On Mon, Aug 31, 2015 at 10:31 PM, Ben Scholzen 'DASPRiD' > wrote: > > Hello, > > > > I've written up an RFC for supporting generic classes and methods in PH= P, > > and I'd love to hear your thoughts about it. > > > > https://wiki.php.net/rfc/generics > > > > Cheers, > > -- > > Ben Scholzen 'DASPRiD' > > Community Review Team Member | mail@dasprids.de > > Zend Framework | http://www.dasprids.de > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > Hello, > > I would love to see generics in PHP, but I have a few questions for your > RFC. > > class Bazz > > Why did you use this syntax for forcing extending/implementation? I > know this is the syntax C# uses, but it doesn't fit PHP. I think it > should be "extends" or "implements", because in PHP : has a different > meaning. > > Also, how do you specify multiple constraints? > > Do you have any idea how it would work internally and if there was > some performance hit while using generics, and if it would also slow > down existing apps that don't use generics? > > I hope this RFC will have positive comments, and someone who is > capable of writing C will help you out with it so there's a patch for > people to review - because I'm not sure if this RFC can get anywhere > without a patch. :( > > Regards > Pavel Kouril > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Hi Ben, Now that I have substantive questions, including the list :) In the following: class SomeList { public static function fromArray(array $a): SomeList { $list =3D new SomeList(); $list2 =3D new SomeList(); return $list; } } $list =3D SomeList::fromArray([1, 2]); When fromArray() executes, what type is $list2? or is that an error? If it's an error, what advantage is there to having distinct generic types on the class vs. the method? How do I specify the two generic types I want to use? Another thing I'd like to make sure I understand, how does this interact with strict types (and non-strict)? new Entry(1, 2);//I assume it should type-juggle declare(strict_types =3D 1); new Entry(1, 2);//I assume it should throw error I'm interested to see if PHP can get generics going. I hope hashing out some more details might garner more interest. Thanks, John --089e0118487437910c051f054e50--