Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99829 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37542 invoked from network); 11 Jul 2017 02:37:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jul 2017 02:37:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@bohwaz.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@bohwaz.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain bohwaz.net designates 5.135.163.151 as permitted sender) X-PHP-List-Original-Sender: php@bohwaz.net X-Host-Fingerprint: 5.135.163.151 sanguine.kd2.org Received: from [5.135.163.151] ([5.135.163.151:42448] helo=mail.kd2.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B0/14-47109-7E934695 for ; Mon, 10 Jul 2017 22:37:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=bohwaz.net; s=mail; h=Message-ID:References:In-Reply-To:From:Date:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:To; bh=LneWMpQVwAanmObG+MaCYMwy7FEirynTFbf1ezIc5hM=; b=mMZOBy434VjkUdnzFRTmqD0QMu1l9P3eT/zbkxM0TbIFSDhLlP9L4MgA7FeZ0YR1u34AljTGJbKvXqVUQvP8xKW+OmVmBSvVg6ZxEhbtIdQ8PuudfxSxAeTrRrbAtN/AwtX1zREDB7GP4SLd+jVDLN4tVK+JbVtv1t6koYmzf3Y=; Received: from narragoon by mail.kd2.org with local (Exim 4.84_2) (envelope-from ) id 1dUl3E-0001Tj-S4 for internals@lists.php.net; Tue, 11 Jul 2017 04:37:24 +0200 To: internals@lists.php.net X-PHP-Originating-Script: 0:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 11 Jul 2017 14:37:24 +1200 In-Reply-To: <4dc7b920-6f34-8f39-0fe8-8a289ae67f3f@gmail.com> References: <827b77ce-f2b7-930a-34cb-ce11ebc2d531@php.net> <4dc7b920-6f34-8f39-0fe8-8a289ae67f3f@gmail.com> Message-ID: X-Sender: php@bohwaz.net User-Agent: Roundcube Webmail/1.1.5 Subject: Re: [PHP-DEV] OBJECT_OPERATOR vs. DOUBLE_COLON From: php@bohwaz.net (BohwaZ/PHP) Le 06/07/2017 16:46, Stanislav Malyshev a écrit : > Hi! > >> I think that using :: on a variable that contains an object should not >> "fall back" to a static access on the object's class. Instead the >> runtime should error out. > > Why should it not do what it does now? What would it achieve? I don't > see any improvement in changing that - it may break code that is using > this facility, and it won't make anything better. True, this is an > exotic and non-obvious feature, but many languages have such features, > which are used only by people that need them. If we proposed to add > such > feature, true, it may be too exotic to be added on its own merits, but > since it is already there (and, probably, used in some code somewhere) > - > why bother messing with it? I don't see how just leaving it be hurts > anything. True. I'm using that feature all the time to access static variables and constants, it's just more convenient to use the variable referencing the object than having to remember and type the name of the class (plus it's more obvious when reading the code back). Though I very rarely use it for accessing static methods, I don't see why this should throw an error, this feature makes sense as '::' is always for accessing static stuff, it is quite logic in the end: :: for static (constants, static variables, static methods) -> for the rest I think this feature is documented somewhere in the doc, that's where I learnt it from if I remember correctly.