Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-06 Thread president
>> > The "original purpose" being, specifically, "smarter class members", >> > correct? (The internal syntax to define them we can bikeshed later; >> > determining the external syntax and semantics has to come first.) >> >> Well when saying "original purpose" I was referring to exactly this: >> >>

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-06 Thread president
> On 5 December 2010 16:47, wrote: >> If I have an object called "PiggyBank", with the property "dollars" set >> to >> 5, "dimes" set to 4 and "nickles" set to 1, then I get the contents of >> the >> property "Total", I can predict it will give me the value 5.45.  That >> is >> what properties a

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-06 Thread Richard Quadling
On 5 December 2010 16:47, wrote: > If I have an object called "PiggyBank", with the property "dollars" set to > 5, "dimes" set to 4 and "nickles" set to 1, then I get the contents of the > property "Total", I can predict it will give me the value 5.45.  That is > what properties are really for.

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-05 Thread Kalle Sommer Nielsen
Hi Dennis 2010/12/6 : > Could this easily be used (and would it make sense to use them) in this > situation?  I think the best solution is for get/set to be keywords, but > only in the context of a property definition.  Will this accomplish the > task? I'm sure it can be done, but I'm not sure h

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-05 Thread president
>> Interesting.  So you are saying that once a word is a keyword in PHP, it >> cannot be used as a name, anywhere?  So for example, you are saying I >> cannot create a variable called $function?  If that is the case, that is >> extremely odd.  I would expect that get/set could be keywords when used

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-05 Thread Larry Garfield
On Sunday, December 05, 2010 11:07:49 am presid...@basnetworks.net wrote: > > The "original purpose" being, specifically, "smarter class members", > > correct? (The internal syntax to define them we can bikeshed later; > > determining the external syntax and semantics has to come first.) > > Wel

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-05 Thread Kalle Sommer Nielsen
Hi Dennis 2010/12/5 : > Interesting.  So you are saying that once a word is a keyword in PHP, it > cannot be used as a name, anywhere?  So for example, you are saying I > cannot create a variable called $function?  If that is the case, that is > extremely odd.  I would expect that get/set could b

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-05 Thread president
Hi Chad, > Having thought a bit about this, there are a couple of initial > problems I see, and, more importantly, I'm not convinced that the > stated problem (encapsulation) requires the addition of a new language > construct (i.e. a "property" as distinct from a "class member"). In > fact, I th

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-05 Thread president
>>> How does one get a reference to a property, if a property is just a >> collection >>> of methods with fancy behavior? That makes properties a first class >> entity, >>> which is an entirely different bit of brain bending. >> >> Its the same concept as having a reference to a function, where yo

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-05 Thread president
>> Its a defacto standard. Of course there is nothing stopping PHP from >> implementing properties that way, but by going against the standard set >> by >> the rest of the industry, it is very confusing for programmers coming >> from >> other lang

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-05 Thread president
> In a multi-user system, any of these values could be different from > one moment to the next. > > class Account{ > public property $AvailableBalance{ > get{ >return $this->CreditLimit - ($this->AccountBalance - $this->OnOrder); > } > } > } > > This hides the mechanics away and tells any

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-03 Thread Arvids Godjuks
Ok, sorry for the buzz, have to re-read it then to catch up. 2010/12/3 la...@garfieldtech.com : > On 12/3/10 7:12 AM, Arvids Godjuks wrote: > >> I'm sorry if in last 10-15 emails there was any change to better >> understanding the PHP, I just didn't follow any more. I'm sorry if I >> offend you in

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-03 Thread la...@garfieldtech.com
On 12/3/10 7:12 AM, Arvids Godjuks wrote: I'm sorry if in last 10-15 emails there was any change to better understanding the PHP, I just didn't follow any more. I'm sorry if I offend you in any way by this e-mail, but really... I think it has to stop. Don't push features witch are inconsistent w

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-03 Thread Richard Quadling
On 3 December 2010 12:53, wrote: >> On 2 December 2010 13:51,   wrote: 2010/12/1 Richard Quadling > On 1 December 2010 09:22, Stas Malyshev > wrote: >>> ... >>> Why change the expected behavior of isset? If a property has not been set then isset must return fals

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-03 Thread Arvids Godjuks
Hi Dennis! Could you please stop trying to push the feature like it is in C#? PHP is a different language, with absolutely different purpose and with it's specifics - both as historically and based on it's purpose as a WEB development language. I admire your passion, but really, the amount of e-ma

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-03 Thread president
> On 2 December 2010 13:51, wrote: >>> 2010/12/1 Richard Quadling >>> On 1 December 2010 09:22, Stas Malyshev wrote: >> ... >> >>> 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. >> >>

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread Chad Fulton
Having thought a bit about this, there are a couple of initial problems I see, and, more importantly, I'm not convinced that the stated problem (encapsulation) requires the addition of a new language construct (i.e. a "property" as distinct from a "class member"). In fact, I think it is better impl

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread la...@garfieldtech.com
On 12/2/10 8:42 AM, presid...@basnetworks.net wrote: How does one get a reference to a property, if a property is just a collection of methods with fancy behavior? That makes properties a first class entity, which is an entirely different bit of brain bending. Its the same concept as havi

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread Richard Quadling
On 2 December 2010 13:51, wrote: >> 2010/12/1 Richard Quadling >> >>> On 1 December 2010 09:22, Stas Malyshev wrote: > ... > >> 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. > > > Thats simple then

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread Lester Caine
presid...@basnetworks.net wrote: >> Its a defacto standard. Of course there is nothing stopping PHP from >> implementing properties that way, but by going against the standard set >> by >> the rest of the industry, it is very confusing for programmers coming >> from >> other languages to l

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread president
Hi Larry, >> Hmm, I would have programmed it liked this: >> >> if ($account->beneficiary != null) { >> print $account->beneficiary->name; >> } >> >> To me, if a property is "not set", it means it does not exist and will >> not >> be a valid property at any point in the object's lifetime. Null

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread president
> See, here's the fundamental problem we're running into. There's three > different definitions of what a property is that we keep bouncing between, > each of which will dictate both syntax and semantics: > > 1) Properties are a smart masking layer over class members, like a smarter > __get/__set,

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread president
> presid...@basnetworks.net wrote: >> I feel that the downfall of this syntax, is that the get and set methods >> can easily be scattered at either end of a class definition. With the >> syntaxes I provided, it is easy to tell which of the methods a property >> has defined at a quick glance, becau

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread president
> 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 so

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread president
Hi Derick, >> Link to the RFC: >> http://wiki.php.net/rfc/propertygetsetsyntax > > -1 > > Derick Care to elaborate? I'm not sure much consideration will be taken of your opinion unless you put some words behind it. I am curious to know why you did not like the RFC? Regards, - Dennis -- PHP I

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread president
Hi Lester, >> Its a defacto standard. Of course there is nothing stopping PHP from >> implementing properties that way, but by going against the standard set >> by >> the rest of the industry, it is very confusing for programmers coming >> from >> other languages to learn PHP. A good example is

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread president
Hi Stefan, >> 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. >> Sometimes the functionality PHP adds by going its own way is worth it

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread president
Hello Stas, > In PHP, of course, class properties are dynamic, so you can add and > delete them at will. It is a standard feature of dynamic languages. For > a person coming from strict compiled language like C# it might be > unusual, but that's how dynamic languages work. No not unusual at all.

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread president
>> 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 s

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread president
>> 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. >> > > Say the property is write-only. How can isset() operate on that? If > the property is read-only, how can you unset() it? I

RE: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-02 Thread Jonathan Bond-Caron
On Thu Dec 2 02:11 AM, Larry Garfield wrote: > > See, here's the fundamental problem we're running into. There's three > different definitions of what a property is that we keep bouncing > between, each of which will dictate both syntax and semantics: > > 1) Properties are a smart masking laye

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Larry Garfield
On Wednesday, December 01, 2010 8:47:50 am presid...@basnetworks.net wrote: > > Actually, I can even think of a concrete use case. Suppose I have an > > object that acts as a facade for a remote object over SOAP, REST, or > > whatever. It is using properties to represent attributes of a remote,

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Larry Garfield
On Wednesday, December 01, 2010 8:28:19 am presid...@basnetworks.net wrote: > > Is this consistent with methods? Do those share a namespace, too? (I > > don't actually recall off the top of my head.) > > methods and variables have their own namespaces. This is because they are > called differe

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Ángel González
presid...@basnetworks.net wrote: > I feel that the downfall of this syntax, is that the get and set methods > can easily be scattered at either end of a class definition. With the > syntaxes I provided, it is easy to tell which of the methods a property > has defined at a quick glance, because eve

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Matthew Weier O'Phinney
On 2010-12-01, Arvids Godjuks wrote: > You are missing the point in PHP in that case. Because PHP is dynamic > scripting language, public properties can be added and removed in the > object on the fly. That's why there is isset and unset that works on > object properties. Consider ActiveRecord, D

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Derick Rethans
On Sun, 28 Nov 2010, presid...@basnetworks.net wrote: > Link to the RFC: > http://wiki.php.net/rfc/propertygetsetsyntax -1 Derick -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread president
Hi Larry, >> 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 >> of two methods that just have a pretty syntax. Methods cannot be unset, >> and nor should properties be allowed to. isset(

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread president
Hi Larry, >>> First of all, I have generally found the Bean-style getter/setter >> approach to >>> be a sign of poor encapsulation to begin with. You shouldn't be >>> mucking >> with >>> internal elements of an object in the first place, period. More >>> details on >>> that here: >>> >>> http://

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Lester Caine
presid...@basnetworks.net wrote: Its a defacto standard. Of course there is nothing stopping PHP from implementing properties that way, but by going against the standard set by the rest of the industry, it is very confusing for programmers coming from other languages to learn PHP. A good exampl

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread president
Hello, > You are missing the point in PHP in that case. Because PHP is dynamic > scripting language, public properties can be added and removed in the > object on the fly. That's why there is isset and unset that works on > object properties. Consider ActiveRecord, DataMappers, ORM, etc. They > u

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Stefan Marr
On 01 Dec 2010, at 14:10, presid...@basnetworks.net wrote: > 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. > Sometimes the functional

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Stas Malyshev
Hi! the rest of the industry, it is very confusing for programmers coming from other languages to learn PHP. A good example is how "==" works differently in PHP than in other languages. In PHP, "===" works like "==" does everywhere else. "(string)'0' == (int)0", for example is true in Not e

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread president
public property Hours read getHours write setHours; >>> >>> I actually like that, though I think we should support the whole >>> existing semantics, i.e. get/set/isset/unset. And probably keep the >>> names, so we don't call the same thing both "read" and "get". >> >> This doesn't make s

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread president
>> Just to chime in on the subject of performance, here is how C# handles >> properties: > > PHP is not a compiled language and as such handling of properties, in > particular, is radically different in PHP. For example, the property > name in expression like $foo->$bar is known only in runtime. Y

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread president
>> 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? Its a defacto standard. Of course ther

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread president
That is true for PHP variables. isset is basically saying "does this 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 regular >>>

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread president
Hi Davey, > Object properties (or members, classic ->var, not this proposed syntax) > CURRENTLY, work this way: > > php -r 'class foo { public $bar; } $foo = new foo(); > var_dump(isset($foo->bar));' > bool(false) > > This is because you are confusing PHP's isset() with a property_exists(). > Is s

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Richard Quadling
On 1 December 2010 12:30, Stas Malyshev wrote: > Hi! > >> No. The prototype of all setters would be the same. As would the >> prototype of all getters. > > But we'd have two sets of properties - one handled by __get/__isset, another > - by get($isset). Not a good idea. So, should properties isset

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Stas Malyshev
Hi! No. The prototype of all setters would be the same. As would the prototype of all getters. But we'd have two sets of properties - one handled by __get/__isset, another - by get($isset). Not a good idea. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)45

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Richard Quadling
On 1 December 2010 10:38, Stas Malyshev wrote: > 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 t

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Richard Quadling
On 1 December 2010 10:23, Eloy Bote Falcon wrote: > 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 pr

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Stefan Marr
Hi Richard: On 01 Dec 2010, at 10:57, Richard Quadling wrote: > 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.

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Stas Malyshev
Hi! 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 I think the idea of new entity of the language looking exactly like old entity of the language but having different rules is kind of non-starte

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Eloy Bote Falcon
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 >> > >>

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread 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

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Stas Malyshev
Hi! Just to chime in on the subject of performance, here is how C# handles properties: PHP is not a compiled language and as such handling of properties, in particular, is radically different in PHP. For example, the property name in expression like $foo->$bar is known only in runtime. --

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Stas Malyshev
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

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Johannes Schlüter
On Tue, 2010-11-30 at 19:31 -0500, presid...@basnetworks.net wrote: > > 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. Even when a property does exist physically (by these

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-12-01 Thread Stefan Marr
Hi: On 01 Dec 2010, at 01:31, presid...@basnetworks.net wrote: >>> That is true for PHP variables. isset is basically saying "does this >>> 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

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread Davey Shafik
Object properties (or members, classic ->var, not this proposed syntax) CURRENTLY, work this way: php -r 'class foo { public $bar; } $foo = new foo(); var_dump(isset($foo->bar));' bool(false) This is because you are confusing PHP's isset() with a property_exists(). Is set. Is the variable (or

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread la...@garfieldtech.com
On 11/30/10 6:29 PM, presid...@basnetworks.net wrote: That is true for PHP variables. isset is basically saying "does this variable exist", and unset is saying to get rid of it. Because properties (as defined in my RFC) are not a variable, but rather a set of methods, I do not think there would

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread president
> Thanks for your reply. > > Fundamentally, a big +1 from my little voice on having setters/getters in > PHP. > > > The issue of documentation is probably that the documentation tools > would have to adapt. As things stand PHPDoc doesn't support > namespaces, so setters/getters would just be added

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread la...@garfieldtech.com
On 11/30/10 5:55 PM, presid...@basnetworks.net wrote: This is a very well-written and well-thought through RFC, Dennis. Nicely done. Thank you! First of all, I have generally found the Bean-style getter/setter approach to be a sign of poor encapsulation to begin with. You shouldn't be muc

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread president
>> That is true for PHP variables. isset is basically saying "does this >> 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 regular > properties... So

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread Arvids Godjuks
You are missing the point in PHP in that case. Because PHP is dynamic scripting language, public properties can be added and removed in the object on the fly. That's why there is isset and unset that works on object properties. Consider ActiveRecord, DataMappers, ORM, etc. They use that 100% to th

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread president
>> That is true for PHP variables. isset is basically saying "does this >> variable exist", and unset is saying to get rid of it. >> >> Because properties (as defined in my RFC) are not a variable, but rather >> a >> set of methods, I do not think there would be any way to "unset" them. >> Like a

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread la...@garfieldtech.com
On 11/30/10 6:15 PM, presid...@basnetworks.net wrote: public property Hours read getHours write setHours; I actually like that, though I think we should support the whole existing semantics, i.e. get/set/isset/unset. And probably keep the names, so we don't call the same thing both "read"

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread president
>> public property Hours read getHours write setHours; > > I actually like that, though I think we should support the whole > existing semantics, i.e. get/set/isset/unset. And probably keep the > names, so we don't call the same thing both "read" and "get". This doesn't make sense. To call i

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread president
> ... > >> /** >>  * >>  */ >> public function set name(string $name) { >>    $this->name = htmlentities($name); >>    $this->name = strip_tags($this->name); >> } >> >> /** >>  * >>  */ >> public function get name($name) { >>    return $this->name; >> } >> >> Greetings, >> Christian >> > > For what

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread president
> This is a very well-written and well-thought through RFC, Dennis. Nicely > done. Thank you! > First of all, I have generally found the Bean-style getter/setter approach to > be a sign of poor encapsulation to begin with. You shouldn't be mucking with > internal elements of an object in the fi

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread president
Hi Benjamin, > I have been working with Objective-c lately, and it has a very flexible > and short way to deal with properties, which could look like this in PHP : > > class TimePeriod { > protected $seconds; > protected $minutes; > protected $hours; > > > @synthesize (rea

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread president
>> I still want to keep the performance implications in mind, as this >> sounds like something that we'd want to use a lot but could also cost a >> lot more than it seems at first glance if we're not careful. > > By making properties in memory a little bigger one might write the > accessors in the

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread Ángel González
Richard Quadling wrote: > (I assume the variable has to be part of the current class or one of its > parents?) Yes. I don't think it makes sense to have a class property actually read a global. If a project really need it (eg. some migration from procedural style to classes), then use the verbose

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread Richard Quadling
On 30 November 2010 12:48, wrote: > Hi Richard, > > > >> I'd really like this feature to be part of PHP. >> >> I don't particularly like the use of what looks like a closure for the >> set/get. > > While it looks like a closure, it may not necessarily be one.  What I have > presented in my RFC is

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread Stas Malyshev
Hi! That is true for PHP variables. isset is basically saying "does this 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 regular properties... So wh

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread Johannes Schlüter
On Tue, 2010-11-30 at 09:15 -0500, presid...@basnetworks.net wrote: > That is true for PHP variables. isset is basically saying "does this > variable exist", and unset is saying to get rid of it. > > Because properties (as defined in my RFC) are not a variable, but rather a > set of methods, I do

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread president
Hello Stas, >> I do not think that properties should make use of a trait-like syntax, >> as >> that is not what a property is about. A property is basically a layer >> of >> syntactic sugar over a pair of methods. The majority of the time when >> writing properties, you will not want to re-use t

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread Richard Quadling
2010/11/29 Ángel González : > Richard Quadling wrote: >> As for reading $seconds directly ... >> >> Well. >> >> If you think of the element that follows read as $this->, then if >> the parser can handle both ... >> >> read $seconds >> read getSeconds >> >> then yes for both. >> >> If not, then

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread Stas Malyshev
Hi! I do not think that properties should make use of a trait-like syntax, as that is not what a property is about. A property is basically a layer of syntactic sugar over a pair of methods. The majority of the time when writing properties, you will not want to re-use them, so I have a hard ti

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread Stefan Marr
Hi: On 30 Nov 2010, at 14:42, presid...@basnetworks.net wrote: > However, it does make sense to be able to define a property as part of a > trait, as again, it is basically just a pair of methods. When I get some > time, I will try to add a syntax for traits to the RFC. The only thing really nec

RE: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread president
Hello, >> Hi! >> >> > Nice RFC, just an idea for an alternative syntax (added to the RFC >> > as >> #2): >> > >> > property Hours { >> >get { return $this->seconds / 3600; } >> >set { $this->seconds = $value * 3600; } // The variable $value >> holds >> > the incoming value to be "set" >> >

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-30 Thread president
Hi Richard, > I'd really like this feature to be part of PHP. > > I don't particularly like the use of what looks like a closure for the > set/get. While it looks like a closure, it may not necessarily be one. What I have presented in my RFC is a syntax, but I make little assumption about how

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Benjamin Dubois
Hi ! This is my first email here (I'm just a PHP user, with only very basic C skills, but I'm working on it), and I would love to contribute to this project. I have been working with Objective-c lately, and it has a very flexible and short way to deal with properties, which could look like this

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Ángel González
Richard Quadling wrote: > As for reading $seconds directly ... > > Well. > > If you think of the element that follows read as $this->, then if > the parser can handle both ... > > read $seconds > read getSeconds > > then yes for both. > > If not, then I'd guess that the getSeconds version shoul

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Johannes Schlüter
On Mon, 2010-11-29 at 13:40 -0600, la...@garfieldtech.com wrote: > I still want to keep the performance implications in mind, as this > sounds like something that we'd want to use a lot but could also cost a > lot more than it seems at first glance if we're not careful. By making properties in m

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread la...@garfieldtech.com
On 11/29/10 12:41 PM, Johannes Schlüter wrote: On Mon, 2010-11-29 at 12:18 -0600, la...@garfieldtech.com wrote: Another advantage here would presumably be performance. If there's no getter defined then the engine could simply map $foo->bar to the class member directly (which is really fast) and

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Johannes Schlüter
On Mon, 2010-11-29 at 12:18 -0600, la...@garfieldtech.com wrote: > Another advantage here would presumably be performance. If there's > no > getter defined then the engine could simply map $foo->bar to the > class > member directly (which is really fast) and not to a method, so > there's > no a

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread la...@garfieldtech.com
On 11/29/10 8:30 AM, Ángel González wrote: What about allowing this syntax to attach the property to a variable? For instance: = 0&& $seconds< 60) $this->seconds = $seconds; } public function setMinutes($minutes) { if ($minutes>= 0&& $minutes< 60) $this->minutes =

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread la...@garfieldtech.com
On 11/29/10 11:51 AM, Jonathan Bond-Caron wrote: Right, it looks the same but the subtle difference is 'property Hours' wouldn't be registered as a class. It's just container code for get(), set() methods that would get 'compiled' into opcodes in the class TimePeriod (the property exists vs. sea

RE: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Jonathan Bond-Caron
On Mon Nov 29 09:27 AM, Stas Malyshev wrote: > Hi! > > > Nice RFC, just an idea for an alternative syntax (added to the RFC > > as > #2): > > > > property Hours { > > get { return $this->seconds / 3600; } > > set { $this->seconds = $value * 3600; } // The variable $value > holds > > the i

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Richard Quadling
2010/11/29 Ángel González : > Richard Quadling wrote: > setMilliseconds() should have $value as parameter instead of a magic name. > > What about allowing this syntax to attach the property to a variable? > > For instance: > > class TimePeriod > { >    protected $seconds; >    protected $minutes;

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Stas Malyshev
Hi! public property Hours read getHours write setHours; I actually like that, though I think we should support the whole existing semantics, i.e. get/set/isset/unset. And probably keep the names, so we don't call the same thing both "read" and "get". Having them called __get etc. woul

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Matthew Weier O'Phinney
On 2010-11-29, Stas Malyshev wrote: > > Nice RFC, just an idea for an alternative syntax (added to the RFC as #2): > > > > property Hours { > > get { return $this->seconds / 3600; } > > set { $this->seconds = $value * 3600; } // The variable $value holds > > the incoming value to be "set"

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Matthew Weier O'Phinney
On 2010-11-29, Richard Quadling wrote: > On 28 November 2010 23:18, wrote: > > Link to the RFC: > > http://wiki.php.net/rfc/propertygetsetsyntax > > > > Thanks, > > Dennis Robinson > > I'd really like this feature to be part of PHP. > > I don't particularly like the use of what looks like a clos

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Ángel González
Richard Quadling wrote: > I'd really like this feature to be part of PHP. > > I don't particularly like the use of what looks like a closure for the > set/get. > > I used to code in Delphi and I always like the way in which their > properties were defined. > > Essentially, the setter and getter ar

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Stas Malyshev
Hi! Nice RFC, just an idea for an alternative syntax (added to the RFC as #2): property Hours { get { return $this->seconds / 3600; } set { $this->seconds = $value * 3600; } // The variable $value holds the incoming value to be "set" } class TimePeriod { private $seconds;

RE: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Jonathan Bond-Caron
On Sun Nov 28 06:18 PM, presid...@basnetworks.net wrote: > > Link to the RFC: > http://wiki.php.net/rfc/propertygetsetsyntax > Nice RFC, just an idea for an alternative syntax (added to the RFC as #2): property Hours { get { return $this->seconds / 3600; } set { $this->seconds =

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Richard Quadling
On 28 November 2010 23:18, wrote: > Link to the RFC: > http://wiki.php.net/rfc/propertygetsetsyntax > > Thanks, > Dennis Robinson I'd really like this feature to be part of PHP. I don't particularly like the use of what looks like a closure for the set/get. I used to code in Delphi and I alway

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-29 Thread Chad Fulton
On Sun, Nov 28, 2010 at 11:48 PM, Christian Kaps wrote: ... > /** >  * >  */ > public function set name(string $name) { >    $this->name = htmlentities($name); >    $this->name = strip_tags($this->name); > } > > /** >  * >  */ > public function get name($name) { >    return $this->name; > } > > G

Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP

2010-11-28 Thread Christian Kaps
Hi, I like the idea of the property get/set syntax, but in my opinion it doesn't figure with PHP's syntax, because it breaks the readability. The problem for me is the nesting of the inner set and get. How do you document these syntax. /** * */ public $name { /** * */ ge

  1   2   >