Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88156 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42357 invoked from network); 11 Sep 2015 16:08:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Sep 2015 16:08:25 -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.223.176 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.223.176 mail-io0-f176.google.com Received: from [209.85.223.176] ([209.85.223.176:34759] helo=mail-io0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3F/C0-37684-87CF2F55 for ; Fri, 11 Sep 2015 12:08:24 -0400 Received: by iofb144 with SMTP id b144so103762063iof.1 for ; Fri, 11 Sep 2015 09:08:21 -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:date:message-id:subject :from:to:cc:content-type; bh=mYVGe9M/fhWcMOufKUUXC7zSX1Za92OVZ2wZzccSmyQ=; b=GvB/xgmLoVle9KfY/DwBlt9PfQjHVBIhQWQMHkh85EXFEH/CRew052r9LitKSp4G2t TtQDQf+bXM08O8ROrZ8xV35eT3BA2J5HqfFQJvpuZebrI+Tbwl8GjvfPhbLFNSmTmGAt FxoiDqso/Y61yVJblemWXv3SZjZ8EHOSpFUuHyEGnVHor22XFIS4/FYrhgZhBAHJLX41 4UXfTcOPc+3Xmua5Qbw889btQgN0UAsmy6VJtyIGJP4DqJh2xocKHaw6/5Te1Z+wNaFD x9I9/9ntVPjB/AQ8Ivyd6ynBQDlkPVZXvSQPN/pG/z5BmAW2egBNXR0EhJO1/J+fgwFO vU8w== MIME-Version: 1.0 X-Received: by 10.107.34.85 with SMTP id i82mr5774338ioi.129.1441987701681; Fri, 11 Sep 2015 09:08:21 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.79.37.71 with HTTP; Fri, 11 Sep 2015 09:08:21 -0700 (PDT) In-Reply-To: References: <55E4B9AA.9060906@dasprids.de> <55F20B8D.3010805@dennis.birkholz.biz> <55F20E72.6050309@dasprids.de> Date: Fri, 11 Sep 2015 10:08:21 -0600 X-Google-Sender-Auth: c_YW3HZvqdOjEfqP1Hy3WozK5dA Message-ID: To: Korvin Szanto Cc: "Ben Scholzen 'DASPRiD'" , Dennis Birkholz , internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Generic classes and methods RFC From: levim@php.net (Levi Morrison) On Fri, Sep 11, 2015 at 10:00 AM, Korvin Szanto wrote: > Levi, > It's my understanding that the "type variable" is a member of the instance > and not of the class. In at least java, generics are unavailable in static > context[1] though they can be specifically defined on the static method > itself[2]. > > [1] > http://stackoverflow.com/questions/936377/static-method-in-a-generic-class > [2] https://docs.oracle.com/javase/tutorial/extra/generics/methods.html > > On Fri, Sep 11, 2015 at 8:28 AM Levi Morrison wrote: >> >> On Thu, Sep 10, 2015 at 5:12 PM, Ben Scholzen 'DASPRiD' >> wrote: >> > Hi Dennis, >> > >> > thanks for your feedback, see my answers below: >> > >> >> 1. static methods: >> >> >> >> class Foo { >> >> public static function test() { >> >> } >> >> } >> >> >> >> how can I call the method: >> >> a) Foo::test() >> >> or >> >> b) Foo::test() >> >> >> >> in case b), would the generic methods not be a duplication? >> > >> > >> > Case a) is correct here. A static method is not in the context of an >> > instance, so it doesn't know about the class boxing by itself. >> >> I think b would be correct. Can you explain this rationale a bit more? This may be how it works in Java, but this is not Java. All behavior must be outlined and justified, especially because not all languages behave the same as Java with regards to generic-like behavior. Notably C++ does not share this characteristic. If this generic ability is confined only to classes/interfaces and only to instance methods that is a large limitation. Even if that is what is decided there must be rationale for choosing it to be that way.