# from Andy Armstrong
# on Sunday 01 April 2007 07:53 am:

>Agreed. May I propose the additional requirement that the  
>documentation contain a lengthy treatise on the benefits of true[1]  
>object orientation?
>
>[1] For whichever value of 'true' the author prefers.

Yes, but then it should also include a requirement that all accessor 
methods be coded longhand.  No Class::Accessor, Class::Accessor::Classy 
or Moose or anything silly like that.  I suppose it might be okay to 
allow inlined typeglob assignment of generated accessors IFF they're 
created in a recursive lexically-scoped function in a BEGIN block.

  BEGIN {
    my $def = sub {
      my $setter = sub {...};
      my $getter = sub {...};
      .... # bit of hand-waving
      no strict 'refs';
      *{$setname} = $setter;
      *{$getname} = $getter;
    };
    my %accessors_for; # special overrides go in here
    my $mk_accessors; $mk_accessors = sub {
      my $name = shift(@_) or return;
      ($accessors_for{$name} || $def)->($name); # lexical polymorphism
      $mk->accessors(@_);
    };
    $mk_accessors(qw(foo bar baz));
  }

That's just my first-crack at it though.  We should probably make $def 
recursive and leverage ternary parametric polymorphism to get rid of 
the $getter/$setter variables.

  my $def; $def = sub {
    (@_ % 2) ? (map({$def->($_ . 'et', @_)} qw(g s))) : (
      sub {
        my ($type, $name) = @_;
        my $subref = eval('sub {shift->{' . $name . '}' . (
          ($type =~ m/^s/) ? '= shift' : . '') . '}');
        no strict 'refs'; *{$type . '_' . $name} = subref;}->(@_);
    );
  };

I think it also needs a package global variable containing a subref for 
easy customization/overrides of the setter (though I suppose we would 
be better off with a subref-wrapped eval'd environment variables 
PERL_GETTER and PERL_SETTER?)

I propose that we standardize this (in the peterbuilt normal form, of 
course) and make it part of the uses_oo metric (requiring verbatim 
pastage save the %accessors_for dispatch declaration.)  Now the only 
question is whether it should use inside-out objects and/or a tied 
dispatch table connected to an ftp server.

--Eric
-- 
The only thing that could save UNIX at this late date would be a new $30
shareware version that runs on an unexpanded Commodore 64.
--Don Lancaster (1991)
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------

Reply via email to