On 10/10/12 21:41, Jazzer Dane wrote:
Here's my feedback on some current outstanding issues/suggestions:
1) Default value: I think having functionality for a default value is
necessary, but I'm also thinking it may already be implementable within the
current syntax.
class Test {
private $seconds;
public $hours {
get() {
if(!is_null($this->seconds)) {
return $this->seconds;
} else {
return 10; // 10 is default
}
}
}
}
The above should work fine in many scenarios, right?
We could perhaps then claim that the issue may rather be that we need
access to the variable *$hours* itself inside of the get/set/etc functions,
which I think has been brought up before - though I'm not so sure how
sensible that is. Whether we need that or not is up in the air.
I think the syntax for defaults would be:
class UsingInitialValue {
private $seconds = 36000;
public $hours {
get() { return $this->seconds/3600;}
}
}
class UsingLazyLoad {
public $seconds {
get() { return $this->seconds = 36000;}
set($value) {$this->seconds = (int) $value;}
}
}
class UsingConstructor {
public $seconds {
set($value) {$this->seconds = (int) $value;}
}
public function __construct(){
$this->seconds = 36000;
}
}
I think I've got those all right...
Cheers,
David
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php