Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77781 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79702 invoked from network); 4 Oct 2014 19:21:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Oct 2014 19:21:03 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.44 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.44 mail-wg0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:61460] helo=mail-wg0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/99-11734-E9840345 for ; Sat, 04 Oct 2014 15:21:03 -0400 Received: by mail-wg0-f44.google.com with SMTP id y10so3760168wgg.27 for ; Sat, 04 Oct 2014 12:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=7k38cH8BAlopGFdXCxSEDd/4EV1clQzSOYCsDmuoDJk=; b=O5E10cJlcKjitfydqBfvBwt8Iv2dGHEwRSuT/OkCbW125gjNqbheo0gq0p5cKYSoAq OUpZYsTNn5+fr11aC/9kO7giSChbsxA3Ww/X5nqmDLiBNYUbnzcx9XsXCaj8nLXiP4Nd sBNls0D1VWcfXsem9JDekK6XOQEjkaC6AtwTO1EFWXjxzh28Uegq4zMBfGbD9mQEO/Jx b8GiNDuWTOAJwSuJc3ues8NN7HQH1BeZaR/1unbiYWIxY1xLisLEUla8Bu2lpiB7AkYw ed9yDS6vLEVY8byxIwxIgxkrLkZP1STNk3TlRBvAo4qOcDHa1i/aQ4oYM5yOvdP+nDzZ ROuA== X-Received: by 10.194.123.200 with SMTP id mc8mr4523227wjb.96.1412450458885; Sat, 04 Oct 2014 12:20:58 -0700 (PDT) Received: from [192.168.0.2] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id ul1sm11763830wjc.9.2014.10.04.12.20.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 04 Oct 2014 12:20:58 -0700 (PDT) Message-ID: <54304897.3020005@gmail.com> Date: Sat, 04 Oct 2014 20:20:55 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: internals@lists.php.net References: <42.58.10205.32DCE245@pb1.pair.com> <54301BE7.2060703@gossimaniac.net> In-Reply-To: <54301BE7.2060703@gossimaniac.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [PHP7] Remove the function keyword from class methods? From: rowan.collins@gmail.com (Rowan Collins) On 04/10/2014 17:10, Thomas Gossmann wrote: > Hence, for php-beginners, this example of a simple class is a good > start, which can also be used educating them in OOP by adding the more > advanced parts - instead of letting them write function when this > actually is a method (In my eyes, education failed here). I'm not sure there is really as clear-cut a distinction as you imply here, such that the word function is "wrong" when used for a method. PHP has 4 different types of "sub-routines" (unless I've forgotten one): - global "functions", which needn't return anything, so encompass what some languages call "procedures" - object/instance "methods", which are "virtual" (polymorphic), inheritable and overridable subroutines called on an instance, with the magic variable $this defined - "static methods", which have the same inheritance and overriding semantics as methods, and have access to private and protected members of the class, but do not require an instance, and do not define $this - "anonymous functions", or "closures", which are actually a complete object encapsulating both code and state Different languages call these concepts, and other variations on the same themes, by various names. In PHP, they are all introduced by the keyword "function", which indicates "here begins a sub-routine declaration". -- Rowan Collins [IMSoP]