Re: prototypes for getters and setters.

From: Date: Wed, 13 Nov 2002 05:10:22 +0000
Subject: Re: prototypes for getters and setters.
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-90940@lists.php.net to get a copy of this message
the trouble is that you will make pubvar a reserved word, and you force the user to use a fixed standard for set/get -- eg. some users may like get_orange, others may want getOrange.... It also makes the assumtion that the user knows how the syntax works.. - eg. searching the file for getOrange would return nothing... Regards Alan John Coggeshall wrote:
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 | |


« previous php.dev (#90940) next »