Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50775 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75540 invoked from network); 1 Dec 2010 13:10:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2010 13:10:57 -0000 Authentication-Results: pb1.pair.com smtp.mail=president@basnetworks.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=president@basnetworks.net; sender-id=unknown; domainkeys=good Received-SPF: error (pb1.pair.com: domain basnetworks.net from 208.97.132.202 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.202 caiajhbdccac.dreamhost.com Linux 2.6 Received: from [208.97.132.202] ([208.97.132.202:43624] helo=homiemail-a23.g.dreamhost.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A3/62-62427-F5946FC4 for ; Wed, 01 Dec 2010 08:10:56 -0500 Received: from homiemail-a23.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a23.g.dreamhost.com (Postfix) with ESMTP id AEAC84B0085; Wed, 1 Dec 2010 05:10:52 -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=MvSf5pcKypk37ZQ+tsJJmmZ//wave5lqOqM/VZWSJNkye gtn0fjJQ6slo7BMuBOtR0nRx8br+iCovSfJmRdg4elsACdr7VIOzamv2C+GMxHvT Z5kGiZM1mC2tumwESe24Ctf47aAXuGFZ56k3yw3l6yfYsTW6/5J8z6gb9YioXE= 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=ElQArjJbMxGemR+wE2CcSjPnKdM=; b=4OEVvXYxdquE oKYsTJx3n6Lda7gEF2e+NmE/Ug5XNJBZhoN/2MUSN+p8GypanfvNxVTuiqjqeyZi Hq71s5gvNhHED7vanoCQrNw5ca52LFmo/V0A9mr9MKkb438iOxLmlHAdO/hK8MC+ WexCiW90QMVZ+/4rnf0qufr42wCOLUo= Received: from webmail.basnetworks.net (caiajhbdcbef.dreamhost.com [208.97.132.145]) (Authenticated sender: president@basnetworks.net) by homiemail-a23.g.dreamhost.com (Postfix) with ESMTPA id 4D3E64B0084; Wed, 1 Dec 2010 05:10:52 -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; Wed, 1 Dec 2010 08:10:55 -0500 Message-ID: In-Reply-To: <6EC3583E-E7B7-431D-B544-82135A33E351@stefan-marr.de> 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> <6EC3583E-E7B7-431D-B544-82135A33E351@stefan-marr.de> Date: Wed, 1 Dec 2010 08:10:55 -0500 To: "Stefan Marr" 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 >>>> That is true for PHP variables. isset is basically saying "does thi= s >>>> variable exist", and unset is saying to get rid of it. >>> >>> This is also true for object properties - see magic methods. I don't >>> see >>> why you shouldn't be able to unset them - you can do that with regula= r >>> properties... So what you imagine would happen if you call >>> unset($foo->property) or isset($foo->property)? >> >> Its not a matter of consistency - Properties, as a cross-language >> concept >> are not meant to work that way. > I tend to disagree. > The need to be consistent inside of PHP has precedence over being > consistent with other languages. Unfortunately I find that to be one of the major downfalls of PHP. It sometimes disregards defacto standards that are set across the entire industry, which causes a lot of frustration for new programmers.=20 Sometimes the functionality PHP adds by going its own way is worth it, bu= t often it is just a confusing mess. Thats just my opinion though, YMMV. >> You need to think of a property as a set >> of two methods that just have a pretty syntax. Methods cannot be unse= t, >> and nor should properties be allowed to. isset() should simply tell u= s >> whether a property with the specified name is part of the class or not= . > I think, it really is the other way around. > Properties are meant to give the programmer the illusion that she is ju= st > having a field. > That is abstraction. She does not care about implementation details. > And that is the power of properties. > > isset() and unset() are perfectly fine in that context. > And I do not see a problem to provide the standard semantics for them > automatically, and let the programmer add isset/unset methods to the > property as needed in exactly the same style as get/set. > > There is a good usecase for asking whether a property has been set, for > instance to verify initialization. > And, of course unset has also a useful meaning. It is about the value, = and > even so there are methods around a value, properties are meant to be > values. > There are definitely use-cases where that does not hold, but that is > application specific. > > >> isset() in the way you suggest would just be confusing. It would allo= w >> is >> to say that a property does not exist, when in fact it does exist. Th= is >> is not logical. > From the docu: isset =97 Determine if a variable is set and is not NULL > There is nothing confusing about isset($this->Hours) =3D=3D FALSE in yo= ur > example if isset($this->seconds) =3D=3D FALSE. Right, I understand how it would work, and the reasons why it would "make sense", but it just feels wrong to me. When you unset() a variable in a class, that whole variable is gone. Its not just hiding somewhere, its completely gone. If a property were to "pretend" it is not set, with an isset method, it would still be there - just hiding. That is why it does not make sense to me. - Dennis