Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50814 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40760 invoked from network); 2 Dec 2010 14:02:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Dec 2010 14:02:39 -0000 Authentication-Results: pb1.pair.com header.from=president@basnetworks.net; sender-id=unknown; domainkeys=good Authentication-Results: pb1.pair.com smtp.mail=president@basnetworks.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain basnetworks.net from 208.97.132.145 cause and error) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: president@basnetworks.net X-Host-Fingerprint: 208.97.132.145 caiajhbdcbef.dreamhost.com Linux 2.6 Received: from [208.97.132.145] ([208.97.132.145:36783] helo=homiemail-a12.g.dreamhost.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BC/C0-36645-EF6A7FC4 for ; Thu, 02 Dec 2010 09:02:39 -0500 Received: from homiemail-a12.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a12.g.dreamhost.com (Postfix) with ESMTP id 1900A71406B; Thu, 2 Dec 2010 06:02:36 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=basnetworks.net; h=message-id :in-reply-to:references:date:subject:from:to:cc:mime-version :content-type:content-transfer-encoding; q=dns; s= basnetworks.net; b=KLkNe4ktO9gSKnnScRbopzW9yAwt5kUD8MZ6alJsptr0Z VPe87Je7yHNoyiL3azbfOKdchEGFUcXy0GeF0ML0lJUYGlBpRIJhPyrx6iOBe0z9 1dCYMBxvZkVwn2kozDIPQiQHzx5SdaBCtyYUYXCLmEiME1wzRcsWKcQnwnw5zo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=basnetworks.net; h= message-id:in-reply-to:references:date:subject:from:to:cc :mime-version:content-type:content-transfer-encoding; s= basnetworks.net; bh=kJdO0zMPo+8oY0s0EY+735KxHTw=; b=YBQTL4G+I+x6 85r7YVD7k+eTVEVwx/N5kmN+mfpNGumzMKAeHxJuLxe62xddj7Ctjh+Oa3NkuwST 1PIJLu0SsLVkdeE1h8CJSqvTSpm89HvdLhnH4qsF/YCHfkUdE3eOePEhg3OAuVwO 6ei9/pjCTEMBV8fvCHwyn6vx1HfELlM= Received: from webmail.basnetworks.net (mailbigip.dreamhost.com [208.97.132.5]) (Authenticated sender: president@basnetworks.net) by homiemail-a12.g.dreamhost.com (Postfix) with ESMTPA id 29A9771406A; Thu, 2 Dec 2010 06:02:35 -0800 (PST) Received: from 70.28.48.126 (proxying for 70.28.48.126) (SquirrelMail authenticated user president@basnetworks.net) by webmail.basnetworks.net with HTTP; Thu, 2 Dec 2010 09:02:36 -0500 Message-ID: <7ecd4694dde8948c7af7f46cf0f9f467.squirrel@webmail.basnetworks.net> 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> <4CF625C2.1080606@sugarcrm.com> Date: Thu, 2 Dec 2010 09:02:36 -0500 To: RQuadling@googlemail.com Cc: "Stas Malyshev" , "internals@lists.php.net" User-Agent: SquirrelMail/1.4.21 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP From: president@basnetworks.net >> So we have one set of properties where get and isset use different >> methods >> and another set of properties where get and isset use same method but >> with >> parameter. I think it's not the best way to go. It's better to ignore >> isset >> altogether than this. > > No. The prototype of all setters would be the same. As would the > prototype of all getters. > > The prototype would be ... > > [public|protected|private] property $property { > [public|protected|private] mixed|bool get([bool $isset =3D false]) { > // mixed result for get, bool result for isset > }, > [public|protected|private] mixed|void set(mixed $value [, bool > $unset =3D false]) { // mixed result for set, void result for unset > }, > }; > > > From a user's perspective ... > > echo isset($instance->property) ? 'isset to ' . $instance->property : > 'not isset'; > > This would result in 2 calls ... > > property->get(true) // Let the getter that an attempt is being made to > see if the property has been set. > and > property->get(false) // Let the getter know that the getter is > expected to return the properties value. > > Similarly for the setter. > > $instance->property =3D 'foo'; > unset($instance->property); > > would result in 2 calls ... > > property->set('foo', false) // Let the setter know that it should be > setting the value of the property to 'foo'. > and > property->set(null, true) // Let the setter know that an attempt to > unset the property has taken place. > > > > Maybe the proposal should be changed to ... > > > [public|protected|private] property $property { > [public|protected|private] mixed get() { > }, > [public|protected|private] mixed set(mixed $value) { > }, > [public|protected|private] bool isset() { > }, > [public|protected|private] void unset() { > }, > }; > > (NOTE: Add in abstract and final as appropriate). This last syntax makes far more sense than adding parameters to the get/set methods. The problem however, is what does isset and unset do/return if they are not defined? What if I only want to define the get/set and I do not define the isset/unset? If they are required, properties are far too complex to be useful. But if they are optional, w= e are back to the same problem of what isset() and unset() are supposed to do... - Dennis