Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81506 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79621 invoked from network); 1 Feb 2015 00:24:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Feb 2015 00:24:01 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.52 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.52 mail-pa0-f52.google.com Received: from [209.85.220.52] ([209.85.220.52:58849] helo=mail-pa0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2F/C1-01632-1227DC45 for ; Sat, 31 Jan 2015 19:24:01 -0500 Received: by mail-pa0-f52.google.com with SMTP id kx10so67025801pab.11 for ; Sat, 31 Jan 2015 16:23:58 -0800 (PST) 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:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=pWoukYuSUF/1/mABNLa8lCv0jlIHnPgRma31mEss4pE=; b=YJ2ruCPWcw96Z8sd9gt7zii90+5Fd6fMlUdP7G0nt3uky6Nid5EKZbgBODbxCQITWZ Br14bDFT4m5itRzKYTI6vz8wUUVvO1WLweoBLz//nkAJ4gj3tRmkmHNJkIe6B9CblaIT uzZtpbxFuV0ZMk7EfhEcpMTHKCI2erggh9rksz/ItXnhBFnQunXhlBsnle9f24uPwr0b 0hnaYcCe774ks7oX7DuT20NIrOJCHLWuilai4GRXlSjkE/d9qVE08abpJp8Y6B+juX6N FyOmfo8UaQukTpscX+BYfOl0eCFx7SwgHxhVfqw8xkPg96VtvUY7/tctmRrTU662cch2 kB5g== X-Received: by 10.70.133.200 with SMTP id pe8mr18402570pdb.89.1422750238111; Sat, 31 Jan 2015 16:23:58 -0800 (PST) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id r1sm14669044pdp.83.2015.01.31.16.23.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 31 Jan 2015 16:23:57 -0800 (PST) Message-ID: <54CD7218.9080909@gmail.com> Date: Sat, 31 Jan 2015 16:23:52 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: "S.A.N" CC: internals References: <54CD6AD6.9080209@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Use "caller" keyword, to access object caller. From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > If the caller explicitly send the object as an argument, it worsens > loose depending API. > > And agreed this code looks weird and not well thought-out: > > $holder->object->call($holder); This code explicitly says "object->call() is using $holder". It is clear and unambiguous. If you did it implicitly - i.e. wrote $holder->object->call() and that used $holder under the hood in call() - then you could have modified or even completely destroyed $holder under the assumption that nobody depends on it, but in fact whatever is in $holder->object, unknown to you, would depend on it and would break. Such hidden dependencies are not a good design. > But if have an easy way to get a pointer to the owner, in practice, is > very convenient. It may be convenient in short run, but I think in the long run creating hidden dependencies would make code less robust so it is better not to enable it as a best practice. -- Stas Malyshev smalyshev@gmail.com