Hello Lars,

Tuesday, May 6, 2008, 9:21:12 PM, you wrote:

> Hi Marcus, et al.,

> Am Dienstag, den 06.05.2008, 09:09 -0700 schrieb Jeff Moore:
> [...]
>> I think this is really specifying implementation details in an  
>> interface:

> I agree.

> [...]
>> This looks to me like the best way to handle this in interfaces:
>> 
>> > interface Coord {
>> >  abstract $coord;
>> > }

> I think this is too unspecific. At least the visibility, setter and/or
> getter and type-hint (assuming we will have type hints) should be
> defined. Otherwise defining properties in interfaces become useless as
> it does not tell somebody more except "there is a property".

> interface Something
> {
>      public $property {
>          string public function get();
>          string protected function set(string $value);
>      }
> }

All fine with me. However we *would* need to specify which function is
getter, setter, isset or unset. We need to avoid introducing new keywords,
so I hope __get and so on in the hope that it would help in that direction.
Also note that we do not need to define anything inside the property or we
could choose to exactly do everything there.

public $property {
  string public function __get() {
    return $this->_property;
  }
  string protected function __set(string $value) {...}
}

vs:

public $property {
  __get = getProperty;
  __set = setProperty;
}
string public function getProperty() {
  return $this->_property;
}
string protected function setProperty(string $value) {}

The advantage of keeping everything inside the property definition is that
there is no need at all for any new keyword. And the handlers cannot get
separated. The disadvantage is that the functions are always named __get and
so on for all properties, so PHP would need to do an internal renaming.
Which means we probably would not be able to call the functions manually.
That larger handlers could clutter the code doesn't appear to be a
disadvantage for me as it can easily be avoided if the handler just
forwards the call.

The next question I have now is what to do when people want direct access
to the underlying value? Or do we force people to always specify
get,set,isset und unset? Or should we only enforce get/set and have isset
and unset emulated with them (isset()~>isset(get()), unset()~>set(NULL))?

Best regards,
 Marcus


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to