Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50765 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49442 invoked from network); 1 Dec 2010 10:35:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2010 10:35:14 -0000 Authentication-Results: pb1.pair.com header.from=eloybote@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=eloybote@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: eloybote@gmail.com X-Host-Fingerprint: 74.125.83.170 mail-pv0-f170.google.com Received: from [74.125.83.170] ([74.125.83.170:37330] helo=mail-pv0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 71/83-28981-0E426FC4 for ; Wed, 01 Dec 2010 05:35:13 -0500 Received: by pvf33 with SMTP id 33so1298833pvf.29 for ; Wed, 01 Dec 2010 02:35:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=Vu0V7l5J6kJzbLHUOLnerytK8cwtopHrM8v+oYc+5BY=; b=EvX8xIleaSIpe9oLL1n99EYDFpkKDKh4l+HeTrHO6AvE2mLreDIxGiTNFOFF1CFL4E xv+joorc82ejHfRxghlWvplYhq+oQYMi1UUC72A8t/SuNl1mfrzKUaV5ndKHdSrkLoSZ NJxOZNUVu+iO87ftDPuzWOZT6AmhnISGcu6uI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=HHA9TQlHRIHqzXUkcWxhu/e7xTpXaF4XPw/QsKmNvlB1lDCiUqa1eoxIAuND374ldd zwTxUr5Zr44Y02flFqprBgN7rWpsF5XDGcMrO8QFtFtSsSfVwA3FGCgJco15Ivry+GVd av4Arpe2ckrq3dZnSq6CammDVPOa72OMGiDSQ= MIME-Version: 1.0 Received: by 10.142.12.16 with SMTP id 16mr8485427wfl.8.1291199709965; Wed, 01 Dec 2010 02:35:09 -0800 (PST) Received: by 10.142.173.4 with HTTP; Wed, 1 Dec 2010 02:35:09 -0800 (PST) In-Reply-To: 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> Date: Wed, 1 Dec 2010 11:35:09 +0100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=000e0cd179c80bf000049656dc7d Subject: Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP From: eloybote@gmail.com (Eloy Bote Falcon) --000e0cd179c80bf000049656dc7d Content-Type: text/plain; charset=ISO-8859-1 2010/12/1 Eloy Bote Falcon > 2010/12/1 Richard Quadling > > On 1 December 2010 09:22, Stas Malyshev wrote: >> > Hi! >> > >> >> Its not a matter of consistency - Properties, as a cross-language >> concept >> >> are not meant to work that way. You need to think of a property as a >> set >> > >> > Meant by whom? Is there some law of universe that prevents us from >> > implementing the feature? >> > >> >> of two methods that just have a pretty syntax. Methods cannot be >> unset, >> >> and nor should properties be allowed to. isset() should simply tell us >> >> whether a property with the specified name is part of the class or not. >> > >> > If you need methods, why not use methods? If you mimick object >> properties, >> > however, it makes sense to make them work exactly like property, >> otherwise >> > you have to explain why they don't work this way. >> > >> >> isset() in the way you suggest would just be confusing. It would allow >> is >> >> to say that a property does not exist, when in fact it does exist. >> This >> >> is not logical. >> > >> > Sorry, from your answer I don't understand - what happens when you call >> > isset($foo->property) and unset($foo->property)? >> >> If we think of properties as this new entity for the language (rather >> than somehow massaging existing entities to fit a new usage scenario), >> then >> >> isset($instance->property) will always return true for any defined >> property. Even if the getter would return null. This is new behaviour >> and can be easily documented. isset() for a property is more like >> method_exists() than isset() on a variable. >> With regard to unset($instance->property), from the manual ... >> >> "The behavior of unset() inside of a function can vary depending on >> what type of variable you are attempting to destroy." >> >> So, we already have differing behaviour based upon context. Attempting >> to destroy a property should through a non fatal error. >> >> One idea I had was to keep just the get/set property methods and add >> to them an additional parameter ... >> >> > public $seconds { >> public set($value, $unset = False) { >> if ($unset) { >> // unset() has been called on the property. >> // In this instance $value will be Null. >> } else { >> // set the property using the supplied $value. >> } >> }, >> public get($isset = False) { >> if ($isset) { >> // isset() has been called on the property. >> // If the value is a non-destructive calculation >> then maybe >> returning the comparison of the result of the calculation to null. >> } else { >> // return the value for this property. >> } >> } >> }; >> >> So, >> >> isset($instance->property) would call $instance->property->get(True); >> unset($instance->property) would call $instance->property->set(Null, >> True); >> >> This keeps just the 2 property methods. It still allows isset/unset >> and allows the developer the option of handling them. >> >> >> >> >> -- >> Richard Quadling >> Twitter : EE : Zend >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > Why change the expected behavior of isset? If a property has not been set > then isset must return false, and that includes $foo->name = NULL. > > > Regards. > Oops, the mail has been marked has spam because of some URI. Regards. --000e0cd179c80bf000049656dc7d--