hi, wow, thats what you're writing is a chain call. this only works, if the methods of a class return the object $this. but if you need a return value other than $this, simply there is no real way.
and moreover i don't agree with the other arguments. what i'm suggesting is, that in with(){} you are only allowed to use the methods and variables defined in the object you are using with(). as in the sample, you are not using any global functions or else. my opinion is, this it is especially with $this very useful. greetings ----- Original Message ----- From: "Ralph Schindler" <[EMAIL PROTECTED]> To: "Sebastian" <[EMAIL PROTECTED]> Cc: <internals@lists.php.net> Sent: Wednesday, October 10, 2007 6:08 PM Subject: Re: [PHP-DEV] new feature -> with() > >> --------------------------- >> $class=new class; >> >> with($class) >> { >> do_something(); >> do_more(); >> do(); >> } > > What more value does this hold over implementing fluent interfaces which > are already possible? > > Assuming > class Foo { > public function doSomething() { /**code**/ return $this; } > public function doMore() { /**code**/ return $this; } > public function doDo() { /**code**/ return $this; } > } > > You can do this: > > $bar = new Foo() > $bar->doSomething()->doMore()->doDo(); > > or, if you want exceptional fallthrough: > > try { > $bar->doSomething() > ->doMore() > ->doDo(); > } catch (Exception $e) { > ... > } > > -ralph -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php