Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88483 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63508 invoked from network); 24 Sep 2015 20:43:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Sep 2015 20:43:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=codekestrel@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=codekestrel@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.212.175 as permitted sender) X-PHP-List-Original-Sender: codekestrel@googlemail.com X-Host-Fingerprint: 209.85.212.175 mail-wi0-f175.google.com Received: from [209.85.212.175] ([209.85.212.175:34138] helo=mail-wi0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/C0-58589-C5064065 for ; Thu, 24 Sep 2015 16:43:09 -0400 Received: by wicfx3 with SMTP id fx3so44867389wic.1 for ; Thu, 24 Sep 2015 13:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=n1ugBsILql7dDZMjGX6NOqb7p6QsUFD1Rtg54KJeJJ8=; b=WQwttnisNg89Yz79Gvx/QecoiS2qSbNogA0fGlq8Nfqd8+/vktazthVgWXRnEMGSdw iYVOqY2IXK6AyBrG3JOb7XnjOojhxHqW44mGi31OOhtFWqqoqmMSIWDz3tMW1geBdO9i 9R1VHvVlpxaORpxRULCLM1ieGNOTAGVjIttW+2UWs5bqbBWbD5+ZUyo4APhDrsnxP+0U XXYKprbBo1sBlrItaaeBzhGRsN6kqvqgKqFOxRktvyHJbu5fB2H8meTngmZZhJ8pUj1e kiqjC9y9UcpevXDjJSAuKLH6mLTD5Hfo5NGWBEl4mD5Z1cxj9v2wRlwEjw2QcRCpgFgq aZ8w== MIME-Version: 1.0 X-Received: by 10.180.219.106 with SMTP id pn10mr2674130wic.56.1443127385307; Thu, 24 Sep 2015 13:43:05 -0700 (PDT) Received: by 10.27.104.197 with HTTP; Thu, 24 Sep 2015 13:43:05 -0700 (PDT) Date: Thu, 24 Sep 2015 21:43:05 +0100 Message-ID: To: Ben Scholzen , internals@lists.php.net Content-Type: multipart/alternative; boundary=001a11346a702ac10b0520844798 Subject: RFC: Generics From: codekestrel@googlemail.com (Dominic Grostate) --001a11346a702ac10b0520844798 Content-Type: text/plain; charset=UTF-8 Hi Ben & Internals, I spent most of today and yesterday just getting used to the parser language. I was able to implement the basic syntax on most of the constructs, just to get a partial proof of concept going. https://github.com/orolyn/php-src/commit/ee731240eab1e5986152cadaaca6d3e5b921ba7d The generic patterns aren't actually used, this simply "allows" them to be present. Also I haven't yet cleaned up the memory leaks. The hitch I ran into however was function calls. add_to_collection($collection, $object); // Sorry for the rather pointless example. This potentially matches an expression, therefore yacc can't use it. Another (minor) but annoying issue is that nested generics need to be written like: A > // Note the space before the last '>' Else it will match T_SL I don't know if either of these issues can be neatly corrected, ##parsers told me it was impossible without some major hackery, so this might warrant discussion on the tokens used to define generic delimitation. Anyway see parsable example below. Dominic {} class K {} class A extends K implements Y, Z > { public function add(K > $a): Y { } } function sample(A $a) { echo 'OK' . PHP_EOL; } sample(new A()); --001a11346a702ac10b0520844798--