Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50677 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29903 invoked from network); 29 Nov 2010 00:22:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Nov 2010 00:22:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.161.42 mail-fx0-f42.google.com Received: from [209.85.161.42] ([209.85.161.42:50746] helo=mail-fx0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 85/E5-18134-652F2FC4 for ; Sun, 28 Nov 2010 19:22:46 -0500 Received: by fxm11 with SMTP id 11so2895228fxm.29 for ; Sun, 28 Nov 2010 16:22:43 -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:cc:content-type :content-transfer-encoding; bh=bdH3h8/QAeKuT/QFM4qff7Tmpse1YsVqgbAzCBllQhg=; b=SWWDFGvRemMJUqTNzIS6Ercm2JVFRpHIrHAeKhqXppMfm0KPA8MJdNXrquTUpteB2W o99vKAdyBP43Un081q67m6QmK/uT5Id+1yjIBeydXVNZQLk3dZAr5RfP0YrVnVY0Ampo WLivpisRMJcT9Zu1A+u4jVx+Wokiy1sBzffxQ= 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 :cc:content-type:content-transfer-encoding; b=aWby6ZQTNs54cWIUETPD9hslzBCv9p0CnMFnaS/gQx0mmnN91q3i6k+yB7/KHItkr6 AqFMpzhw8uR8JfFb9vLwHxxQxXXAOadUtSHsRC4niRV1ADMGH7K1BsczH+CpAL/VZ1lj 9o8tyrqw87+cncKRAZZmHEVGKikqwTK1vtPSo= MIME-Version: 1.0 Received: by 10.223.125.136 with SMTP id y8mr4584553far.149.1290990163190; Sun, 28 Nov 2010 16:22:43 -0800 (PST) Received: by 10.223.83.142 with HTTP; Sun, 28 Nov 2010 16:22:43 -0800 (PST) In-Reply-To: References: Date: Mon, 29 Nov 2010 01:22:43 +0100 Message-ID: To: president@basnetworks.net Cc: internals@lists.php.net 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: pierre.php@gmail.com (Pierre Joye) hi, Great job, very well written proposal. Quick notice: the readonly keyword work without being used with a method (or the default getter/setter): class A { public readonly propro; } The writeonly property (useful from time to time) is not supported by default but using the custom definitions. I'm all in favour of having that in PHP. However not in an immediate future (ie 5.4) but the next major version. Cheers, On Mon, Nov 29, 2010 at 12:18 AM, wrote: > Hello, > > This is my first time using a mailing list, so please bear with me. > > Some time back I suggested that PHP should have a property get/set syntax > similar to that of Microsoft's C# language. =A0One of the PHP developers > suggested that if I were serious about it, I should write an RFC. =A0I ha= ve > done just that, and I would now like to present my RFC to everyone here i= n > internals, in order to start a discussion on the topic. > > The RFC: > > Many modern languages have a special syntax for writing get/set method > pairs. =A0All that PHP currently supports is __get and __set, which while > great for writing generic get/set methods is nearly useless when it comes > to individual properties. =A0Our only other choice is the age old process= of > writing custom class methods to make our get/set methods. =A0Not only doe= s > this lack any kind of uniformity, but it also complicates the syntax > ($foo->getBar() and $foo->setBar('baz') instead of $foo->bar and > $foo->bar=3D'baz'). =A0I believe that if PHP is going embrace modern > object-oriented design, including encapsulation, than it needs a modern > solution to property getters and setters. > > I wont add much more here, but rather let the RFC itself do the talking. > It is fairly well fleshed out, and should explain everything clearly > enough. > > Link to the RFC: > http://wiki.php.net/rfc/propertygetsetsyntax > > Thanks, > Dennis Robinson > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org