Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50824 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59369 invoked from network); 2 Dec 2010 14:59:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Dec 2010 14:59:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:34693] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/52-46575-654B7FC4 for ; Thu, 02 Dec 2010 09:59:35 -0500 Received: by qyk10 with SMTP id 10so3913154qyk.8 for ; Thu, 02 Dec 2010 06:59:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:reply-to :in-reply-to:references:from:date:message-id:subject:to:cc :content-type:content-transfer-encoding; bh=/+JVJSkTGI0jvND59ODOTRt0unmYXry13VX0rlBzL+g=; b=YwjVwEP/W1q7pOmVMxE/8/cmrIBB1QuQHIBbRRSs3UC1GqtQX/7Z4kK07pzr4p1Ahj EAXTUVnH7tRY1SiWtgNYfHARqYa55kSb5Iq9HkfCSql1TfZzQo58d7NqbDE8MZvyePVf nAMKvPc9J4LgY8HeFtKNzh52KzZaDnQFLds0g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=gcwpwrNE+8gJZDx4FTYmmZt2ziG8wgR1rw309RnezMZLjZtFeCD4HtFYR1fNHNN+Bb F0uerD5sDHJ2Hh2KoApVqUIWYIvfTMoAhIFzzijMplYmg15GdC9NrcgKO+ZLG1U06Drq PqvyfX4m5BP2ogRcY2AXrKzeCXcDtr5wpzByY= Received: by 10.229.228.76 with SMTP id jd12mr87689qcb.291.1291301972617; Thu, 02 Dec 2010 06:59:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.100.130 with HTTP; Thu, 2 Dec 2010 06:59:12 -0800 (PST) Reply-To: RQuadling@googlemail.com In-Reply-To: <8b46dd8e3e991cfe87550a9c55d9ecd8.squirrel@webmail.basnetworks.net> References: <003601cb8fd0$f6494e80$e2dbeb80$@com> <4CF3B855.5010406@sugarcrm.com> <003401cb8fee$1be39840$53aac8c0$@com> <2450924ae03481f5b1382a7f00e5743d.squirrel@webmail.basnetworks.net> <4CF50245.5020807@sugarcrm.com> <4CF5118B.2030300@sugarcrm.com> <1faa4c3db62771335db714507ac2adfa.squirrel@webmail.basnetworks.net> <4CF613EB.40200@sugarcrm.com> <8b46dd8e3e991cfe87550a9c55d9ecd8.squirrel@webmail.basnetworks.net> Date: Thu, 2 Dec 2010 14:59:12 +0000 Message-ID: To: president@basnetworks.net Cc: Eloy Bote Falcon , Stas Malyshev , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP From: rquadling@gmail.com (Richard Quadling) On 2 December 2010 13:51, wrote: >> 2010/12/1 Richard Quadling >> >>> On 1 December 2010 09:22, Stas Malyshev wrote: > ... > >> Why change the expected behavior of isset? If a property has not been se= t >> then isset must return false, and that includes $foo->name =3D NULL. > > > Thats simple then, when isset is invoked, call the get method, and if it > returns null then isset() returns false, but otherwise returns true. =C2= =A0That > was likely just a small oversight on Richard's part. No, it was not an oversight. Calling the getter() in response to isset() will probably result in a change to the value of the property. For a property, isset() can and only be interested in the last value of the property, not the next value. As I understand things, isset() performs 2 tests. First a check to see if the variable exists and then to see if it has a value assigned. For a property, the first part of that equation is fairly simple - the property has to exist or not. The second part though is not easy. A variable will not change value in response to isset(), but, if isset() calls the getter(), then it could and probably would. Calling isset() shouldn't alter anything. Having isset() call the getter() and unset() call the setter() is fine as long as the getter() and setter() know why they are being called. If the developer needs to supply the last value - their choice - then this could be implemented by caching the last value in a local scope static. Completely encapsulated. get($isset =3D false){ static $lastValue; if (!$isset) { // Generate the new value and assign it to $lastValue } return $lastValue; } Richard. --=20 Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY