On 21.02.2008, at 19:09, Andi Gutmans wrote:
I don't think so. I think the value here is not copy&paste but to be
able to encapsulate some functionality which a class can be
decorated with. Giving a basic storage mechanism to that would be
very beneficial in a large amount of uses. Again, I am proposing
private storage only which would be for internal use-only by the
decorating methods.
if someone desperately needs that they could just write a method with
a static variable.
class foo {
function bar($value = null) {
if (!isset($var)) {
static $var = 'bar';
}
if (func_num_args() > 0) {
$var = $value;
}
return $var;
}
}
$foo = new foo();
var_dump($foo->bar());
var_dump($foo->bar('foo'));
var_dump($foo->bar());
ok its a hack .. but you can see how this could work. and you could
even expand it to handle an arbitrary number of "properties" in a self
contained method. all you need to do is find a name that doesnt clash.
again i prefer to keep the feature as simple as possible without
crippeling it the point of not being useful.
regards,
Lukas
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php