On Wed, 2002-11-13 at 02:31, Alan Knowles wrote:
> Thanks to a little chat (and a  few beers) with Zak at the conference, I 
> got wondering if this syntax would be a sensible addition...
[...]
> syntax:
>    var [getter method] [setter method] $variable .....;
+1

Plus, another syntax suggestion (coming in closer to Delphi):
  [type] $var read [getter] write [setter] [= default_value];
e.g.
  var $variable read getBanana write setBanana = 12;

Maybe even adding the "default" keyword:
  [type] $var read [getter] write [setter] default [= default_value];
e.g.
  var $variable read getBanana write setBanana default = 12;

and array offsets as suggested in another mail:
  [type] $var["[]"] read [getter] write [setter] default [=
default_value];
e.g.
  var $variable[] read getBanana write setBanana default = array();

or alternatively
  [type] $var read["[]"] [getter] write["[]"] [setter] default [=
default_value];
e.g.
  var $variable read[] getBanana write[] setBanana default = array();


---------------------------------------------------------------------
[type] is either "var", "public", "private" or "protected"
---------------------------------------------------------------------

The default property is probably best explained in this example:

  class StringList {
    public $strings[] read get write put default = array();

    function get($index) {
      return $this->strings[$index];
    }

    function put($index, $value) {
      $this->strings[$index]= $value;
    }
  }

  $s= new StringList();
  $s['hello']= 'world';

This would be equivalent to 

  $s->strings['hello']= 'world';

and call

  $s->put('hello', 'world');

although the default property is probably quite a bitch to handle
parser-wise.

-- 
Timm
Any sufficiently advanced bug is indistinguishable from a feature


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

Reply via email to