Re: Object method overloading

From: Date: Wed, 13 Aug 2003 23:52:59 +0000
Subject: Re: Object method overloading
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-159504@lists.php.net to get a copy of this message
Well, for instance, you could have the __get and __set functions execute a SQL query or go to a file or whatever. The point, as it seems to me anyway, is to enable a potentially complex internal implementation be exposed with a simple interface. Now as for the implications of that, it's debatable. If nobody is ever going to look at or reuse your code, it's arguable such a feature merits a second glance. Personally, I appreciate these kinds of language features, but perhaps that's because I learned most of what I know about programming in C++. Thanks, -Dan <daniel@electroteque.org> wrote in message news:47590.203.15.102.65.1060817724.squirrel@www.electroteque.org... > What is the point of overloading an object again? > > > Hello, > > > > I realize this stuff isn't set in stone yet, but might I eventually > > expect the following to make two assignments rather than one? > > > > <?php > > > > class overload_test > > { > > function __set($name, $value) { > > echo "__set($name, $value)\n"; > > $this->$name = $value; > > return true; > > } > > } > > > > overload('overload_test'); > > > > $t = new overload_test; > > $t->a = 'Foo'; > > $t->b[0] = 'Bar'; > > print_r($t); > > > > ?> > > > > Output: > > __set(a, Foo) > > overload_test Object > > ( > > [a] => Foo > > ) > > > > Thanks, > > -Dan > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.general (#159504) next »