RE: [PHP-DEV] prototypes for getters and setters.
| From: | John Coggeshall | Date: | Wed, 13 Nov 2002 04:41:44 +0000 |
| Subject: | RE: [PHP-DEV] prototypes for getters and setters. | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-90939@lists.php.net to get a copy of this message | ||
What about something like this...
Class foo {
var $myfoo; // "Private" variable
pubvar $myfoo2; // "Public" variable
}
Class bar extends foo {
pubvar $mystuff;
}
$a = new foo();
$a->setmyfoo2(5);
echo $a->getmyfoo2();
$b = new bar();
$b->setmyfoo2(10);
$b->setmystuff(20);
The point here is that pubvar automatically creates get* and set*.. As
far as overloading, etc is concerned, there would be no need to worry
about it -- the point of these functions is not to overload them (they
should simply be used to get and set member variables)...
John
|-----Original Message-----
|From: Shane Caraveo [mailto:shane@caraveo.com]
|Sent: Tuesday, November 12, 2002 10:04 PM
|To: Alan Knowles
|Cc: php-dev@lists.php.net
|Subject: Re: [PHP-DEV] prototypes for getters and setters.
|
|
|Alan Knowles wrote:
|
|> Shane Caraveo wrote:
|>
|> >>
|> >>
|> >> Anyway before I get carried away and actually test this :) -
|> anybody got
|> >> any thoughts.....
|> >>
|> >> Regards
|> >> Alan
|> >
|> >
|> >
|> >
|> > What's wrong with how overload does this?
|>
|>
|> it has a slight downside in clarity of code - eg. where is that
|> method..
|>
|But it (overload) also does not introduce new syntax, requires no
|changes to the engine, is genericly overrideable in extensions, etc.
|etc. etc.
|
|Shane
|
|
|--
|PHP Development Mailing List <http://www.php.net/>
|To unsubscribe, visit: http://www.php.net/unsub.php
|
|