Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104628 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 78932 invoked from network); 10 Mar 2019 22:56:55 -0000 Received: from unknown (HELO mail-it1-f195.google.com) (209.85.166.195) by pb1.pair.com with SMTP; 10 Mar 2019 22:56:55 -0000 Received: by mail-it1-f195.google.com with SMTP id g17so4003657ita.2 for ; Sun, 10 Mar 2019 12:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sbOIA3p/YBvPxQMUnT4plFbK3Yv/0AUszv/1BJWJ9bU=; b=Dm5rZr0AdC8SX66Dogq4uuAAgQRO715R1ZnuxExFoVMelo4bNixjLp/+fY8j4gef+y 15iwd7KF/uJ3or1FPSfxtc8OeMnLDxkwLp2gvHQops9/CdKTi/heI2vMGmfp8m3S4SJy Wv0rfglSQ475+cqwDu+74QsD5Rn4D4u4LddyuawmC+n0U4lHTLuckBRB0uE55HeA1wKG jQ5tXCXDKf9hkoHaeYVbmiwwcVn33IcTsN1mkNi+rX/NGGQKXfy8x4CztJy91EHJNlcL kl3Isqo3iVt2Uumf2BXJ9k6OaBY4vmKGCSAULJemaVKHKtT17rirehq58/Sy3qFoTjPX kLXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sbOIA3p/YBvPxQMUnT4plFbK3Yv/0AUszv/1BJWJ9bU=; b=SnJ4peOAssv98IgVe2Rzt1YTI1E0K0BJ0jqMTAQQmJnWisEdTgJsaZbQpP9xgk9p+s 1tMl8PqAjKgKalKShx1nvaNufu9XncoWB8XMzcDH8jmenHP6vlcFGW8SJw1qSzHsmJ1c wKhatpdkPDCUAKrPfoulPg0b1dzE+oizCMATIxuuf+9GupJ6LjtJhCcqbXqyebuupYOE OkTZsMcGI/pcimfX0qMX35vEfcOPjzEwm+fXXuQ+wDvfahAIoaqiMS04btMJK+g9whRX CbkmahQQodK4Gq0d2Bc+Z99BxJqkDSVGXcLSiYEUOBlSRzypqTcQprGExMQVdnF5PGdx MMfA== X-Gm-Message-State: APjAAAVJTVIU86/8NQwJK148XkvoUmXv0SS3mzSjMjYvbhtKi/uG6Omd BPMcdHtTnN0qkBl75tvWi9CJiTX6juNlBTweeZw= X-Google-Smtp-Source: APXvYqxoQlS6LezOdj6u27M5mdb+fM3pv+KjNK+9jop2pL0e2HxHhwwwzrg2dJdBMsHtxti2Iixa0UZ2/wwX2xeSfs8= X-Received: by 2002:a24:4d4b:: with SMTP id l72mr13133115itb.177.1552247182575; Sun, 10 Mar 2019 12:46:22 -0700 (PDT) MIME-Version: 1.0 References: <2c497732-96f8-3ef0-bc18-912220fbff4d@gmail.com> In-Reply-To: Date: Sun, 10 Mar 2019 20:46:08 +0100 Message-ID: To: Larry Garfield Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000ebd5d90583c2b52c" Subject: Re: [PHP-DEV] RFC: Locked Classes From: ocramius@gmail.com (Marco Pivetta) --000000000000ebd5d90583c2b52c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Typical scenario (works for either of the properties - note that typed properties that aren't nullable and have no default value also behave the same way): class Foo { private int $a; private $b; public function __construct() { unset($this->b); } public function __get(string $name) { $this->a =3D 123 $this->b =3D 'abc'; return $this->$name; } public function saySomething() : string { return $this->a . $this->b; } } echo (new Foo())->saySomething(); https://3v4l.org/Rn39Q (note: 3v4l doesn't have 7.4, so I simplified it a bit) @rowan: I've stated it multiple times in the past, but if the mechanism is to be removed, then it should be replaced with a language-level concept of laziness then. On Sun, 10 Mar 2019, 20:32 Larry Garfield, wrote: > On Sun, Mar 10, 2019, at 1:52 PM, Marco Pivetta wrote: > > Hi Rowan, > > > > Overall good idea, except that I disagree with the `unset()` being > > disabled: that bit is strictly required for lazy-loading purposes, and > > mostly harmless for userland ("normal" people don't do it, libraries do > it). > > > > Besides that (blocker for me), if this RFC would be enforced in my codi= ng > > standards of choice =F0=9F=91=8D > > > > Does anybody know if this has potential for engine optimizations? > > Marco, have you an example of such lazy-loading tricks? I'm not familiar > with them but would like to be... > > I'm overall +1 here as well, as I am for most things that allow me to mak= e > my code stricter and pickier. (I don't have a strong feeling on unset() > either way.) > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --000000000000ebd5d90583c2b52c--