Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84543 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30549 invoked from network); 11 Mar 2015 13:37:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Mar 2015 13:37:00 -0000 X-Host-Fingerprint: 93.82.116.86 93-82-116-86.adsl.highway.telekom.at Received: from [93.82.116.86] ([93.82.116.86:8069] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/B3-07702-AF440055 for ; Wed, 11 Mar 2015 08:36:59 -0500 Message-ID: To: internals@lists.php.net Date: Wed, 11 Mar 2015 14:36:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 References: <24.71.03288.592FDF45@pb1.pair.com> <54FE20E5.1060605@gmail.com> <55003D12.5010006@gmail.com> In-Reply-To: <55003D12.5010006@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Posted-By: 93.82.116.86 Subject: Re: [PHP-DEV] Request Feedback for Instance Variable Sugar RFC From: mail@deroetzi.de (Johannes Ott) Am 11.03.2015 um 14:03 schrieb Rowan Collins: > Johannes Ott wrote on 10/03/2015 20:46: >> okay indeed the dynamic properties are a problem I didn't think about on >> my suggestion. Without the wish to hijack this thread for another >> typesafety discussion, I must say again that PHP needs a less dynamic >> and more declaratively properties concept in my opinion. > > Yes, I think a standard way to say that a particular object has strictly > declared all its properties, and should not allow would be useful. > > (Even with that, though, I'd be against guessing that "$foo" meant > "$this->foo"; it just makes code harder to read.) > I disagree, programming Java beside PHP since about 15 years now, personally I think always having "this"-keyword, where it is not necassary in a strict OOP-world, makes the code more unreadable for the simple fact it is more to read. >> So I would suggest for now to keep the $this variable, but to make it >> more similar to other OOP-languages I would suggest to remove the >> $-character in front. In my opinion it would fit better to other object >> keywords like parent and self as well. > > Other OOP languages only don't have a sigil such as $ in front of this > if they don't have one in front of *any* variable. Why should $this, > which acts like a normal variable in pretty much every way, drop the $ > when every other variable in the language has one? > > Note that the syntax of parent and self is different, and is consistent > with static member/method access, or more strictly "scope resolution". > You can't pass parent or self around as variables, only use them to > resolve scopes, so they don't have a $. > I only agree a bit, because the keyword "this", is what to call a hybridization, more often used to define the scope of the property or method you want to use, then used really as a pure variable. For example: this->a; or this->some_function(...); just defining the scope as in the current instance is much more used then. some_function($this); > That's what sigils are for - making similar things look similar and > distinct things look distinct. > > Regards, -- DerOetzi