Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50762 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42596 invoked from network); 1 Dec 2010 09:57:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2010 09:57:32 -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.42 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.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:51872] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/42-28981-B0C16FC4 for ; Wed, 01 Dec 2010 04:57:31 -0500 Received: by qwj8 with SMTP id 8so2412741qwj.29 for ; Wed, 01 Dec 2010 01:57:28 -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=4UIDznGLkmFpHhhGHIbjU7iizARMVsrxoz3+dfmi2T0=; b=G7jXxVMTuJLuzaQtu+Dtp8ESg/jYehuz29vTe1MfHGS/lIzo52T3fw6Sq5+bcuflkA uM4UK/wXmdTCf74Z8q2cFwW+QMW3eZakhOnTut9w9nB1Vt5NGQS8A7QNGP/zxkkEK5YI XtKzpZRfSd02wSHzqMYLs6FdJGcgWC2qZtP8E= 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=T/bHQ1oraOkhqldR6GU20aHmz48UdrnBTI112QIzWk465VKcCJH2P1px5YEGlKppij fQjIbD3rNc1p+bmb71txVnhntIV7IG7p5BFiML5sZ9TbKoFR6Gk4mjKatk+wLjGVrSBc NsgANA/f8vRjhvsw1v9t88SaJJirB3C6msNZ4= Received: by 10.229.238.197 with SMTP id kt5mr7295958qcb.25.1291197448640; Wed, 01 Dec 2010 01:57:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.100.130 with HTTP; Wed, 1 Dec 2010 01:57:08 -0800 (PST) Reply-To: RQuadling@googlemail.com In-Reply-To: <4CF613EB.40200@sugarcrm.com> 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 09:57:08 +0000 Message-ID: To: Stas Malyshev Cc: "president@basnetworks.net" , "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 1 December 2010 09:22, Stas Malyshev wrote: > Hi! > >> Its not a matter of consistency - Properties, as a cross-language concep= t >> are not meant to work that way. =C2=A0You 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. =C2=A0Methods cannot be u= nset, >> and nor should properties be allowed to. =C2=A0isset() should simply tel= l 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, otherwis= e > you have to explain why they don't work this way. > >> isset() in the way you suggest would just be confusing. =C2=A0It would a= llow is >> to say that a property does not exist, when in fact it does exist. =C2= =A0This >> 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 ... 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. --=20 Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY