Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93655 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74175 invoked from network); 31 May 2016 16:42:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 May 2016 16:42:05 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 65.55.169.134 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 65.55.169.134 mail-bl2on0134.outbound.protection.outlook.com Received: from [65.55.169.134] ([65.55.169.134:12736] helo=na01-bl2-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 23/6A-26200-CDEBD475 for ; Tue, 31 May 2016 12:42:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=EVHjFW8qISopD+mJRLNGt4huPQrjPEtSemt25IrkGhk=; b=ORgZ0Y4f3U4e4HobsPNQl3gYw0VBhPhweGx469xR50QrOzRZQY/8WkC/szFOkYLSPLV/sHfBXpYiTnF/RDdJxqGPUyolTKiDvTt6YbZZKiAbadkx4fuV2IXmE60xgZNZrVQhjERY1UFgo0yNeGvZifHH+DYqv8S2Mewcnz8H+bE= Received: from BY2PR0201MB1784.namprd02.prod.outlook.com (10.163.72.26) by BY2PR0201MB1781.namprd02.prod.outlook.com (10.163.72.23) with Microsoft SMTP Server (TLS) id 15.1.501.7; Tue, 31 May 2016 16:42:01 +0000 Received: from BY2PR0201MB1784.namprd02.prod.outlook.com ([10.163.72.26]) by BY2PR0201MB1784.namprd02.prod.outlook.com ([10.163.72.26]) with mapi id 15.01.0501.017; Tue, 31 May 2016 16:42:01 +0000 To: Marc Bennewitz , "internals@lists.php.net" Thread-Topic: [PHP-DEV] [RFC] Fix inconsistent behavior of $this variable Thread-Index: AQHRtTC0CwOThBGXuUmMwxcXw+u9D5/HlJiAgABGXQCAAJ17AIAK04bf Date: Tue, 31 May 2016 16:42:01 +0000 Message-ID: References: ,<906d46a8-e0b3-9650-b8e1-be6ab669d545@mabe.berlin> In-Reply-To: <906d46a8-e0b3-9650-b8e1-be6ab669d545@mabe.berlin> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mabe.berlin; dkim=none (message not signed) header.d=none;mabe.berlin; dmarc=none action=none header.from=zend.com; x-originating-ip: [132.245.81.165] x-ms-office365-filtering-correlation-id: 5dbefe46-afef-4038-5665-08d389727db2 x-microsoft-exchange-diagnostics: 1;BY2PR0201MB1781;5:LD0BLHDWExJMVA8jVmlNQLwrfdHREnVcCu+pbi5yoerOMDZpgOGnaa+w4gJIqhcxBLVk5aWh3cF/sXkGP+0vkwd977J8Lx1moBLur5Y/4pUmXUvgcn7ZffYnAq/0d0b2YChMkkhDZLPwSYNAklmryg==;24:SHmIT9ditNRhZwXksPnYTsa5nlQuiLUY2R7dNUDQVfUBdzmtyM9O/Jr2RRyNwNlW7tKCHPdtMW5cmUuI+mhlTbeltv6+IS+rBzCVZJAoyqs=;7:ZhfB+/qQCTChEySJx2aASkNT7biwTMgfX/iFACguXy0UpAb9rzIKuxcNYk2ZiALMlvW3Opv3+02P16zjUwL2+dQPft7JWIkfS3e9NB4u1jYlDjCIWJyJyJW//3H3N8KcPv1xwHAP7EfVJA4s5f5nr1tM0aSww0RG06ok8SXpjZiMit3oUVFfnObMxzpz5+Eo x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB1781; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(23657631684272); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001);SRVR:BY2PR0201MB1781;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB1781; x-forefront-prvs: 095972DF2F x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(979002)(6009001)(24454002)(377454003)(189998001)(74316001)(110136002)(107886002)(77096005)(2501003)(66066001)(2900100001)(15188155005)(2950100001)(19580395003)(5002640100001)(19580405001)(16799955002)(9686002)(15975445007)(5008740100001)(8936002)(122556002)(8676002)(81156014)(81166006)(2906002)(93886004)(10400500002)(54356999)(50986999)(92566002)(87936001)(106116001)(86362001)(76576001)(76176999)(586003)(102836003)(3660700001)(3846002)(6116002)(5004730100002)(3280700002)(99286002)(33656002)(11100500001)(5003600100002)(556834004)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR0201MB1781;H:BY2PR0201MB1784.namprd02.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-originalarrivaltime: 31 May 2016 16:42:01.4675 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 32210298-c08b-4829-8097-6b12c025a892 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0201MB1781 Subject: Re: [PHP-DEV] [RFC] Fix inconsistent behavior of $this variable From: dmitry@zend.com (Dmitry Stogov) changing "$this" into "this" is not an option. This would break 90% of PHP = code :) ________________________________________ From: Marc Bennewitz Sent: Tuesday, May 24, 2016 10:21:02 PM To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Fix inconsistent behavior of $this variable On 05/24/2016 11:57 AM, Rowan Collins wrote: > On 24/05/2016 06:45, Jesse Schalken wrote: >> I'm curious, what is it about $this that makes it special in the first >> place? Can't it be a normal local variable that happens to already be >> assigned at the start of a method? > > There are a few things that take advantage of its specialness, e.g. > > - binding a closure to an object changes the meaning of $this in a way > very different from assigning it into scope with "use($this)" > - a method declared static can detect and throw errors on anything > referencing $this > - when calling parent::foo() from an instance method, the value of > $this needs to be set appropriately on the new method; being able to > reassign $this could lead to some odd behaviour there > > Python's approach is certainly valid, and leads to some different > useful properties, I'm sure, but it's a very different design, not > just a more relaxed attitude to assignment. As of $this is a very special variable where only the engine is (or should) be allowed to change. I would like to ask you if it wouldn't be better to NOT define $this as a special variable including a lot of code to make sure this variable doesn't get re-assigned but instead define this as a keyword like self where the syntax makes sure it can't be re-assigned and it's less special and simpler to learn for beginners. I know it would be a huge BC break but for me it sounds more "right" and could also be introduced in parallel to $this for a long long time but without a lot of overplayed code for $this. Thanks, Marc > > Regadrds, -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php