in reply to Re^3: Tim O'Reilly on Perl
in thread Tim O'Reilly on Perl

Can you give an example of "worse-is-better" in the design of Perl before Perl 6?

Not that I can speak for Larry, but I'd see Perl 5's OO model as an example of worse is better backfiring. While it was an elegant and simple way to shim OO into Perl 4 with the minimal of additional baggage, it made other stuff tricky in the longer term.

Replies are listed 'Best First'.
Re^5: Tim O'Reilly on Perl
by holli (Abbot) on Jul 14, 2005 at 11:52 UTC
    Will we have lvalue methods in Perl 6? Because that's what really bugs me, about Perl 5 OO.
    $obj->SetProperty("something");
    is just ugly, compared to the shiny elegance of
    $obj->Property = "something";


    holli, /regexed monk/

      It does indeed have that already.

      use v6; class test { has $.Property; } my $testing = new test; $testing.Property = 5; $testing.Property.say;

      I beleive that it actualy uses a Proxy object with lvalue attributes, but don't quote me on that. ;)


      ___________
      Eric Hodges

        Gah, ambiguous indirect object notation went away in Perl 6. Mark the invocant explicitly:

        my $testing = new test:;

        Or make a method call look like a method call:

        my $testing = test.new()
      You bet you will have them! Only such a method will be spelled 'is rw'. Well, until Larry changes his mind on this...

      Is there something wrong with Perl 5's lvalue attribute? As far as I can tell, it produces rather functional lvalue accessors:

      package Foo; sub foo : lvalue { my $self = shift; warn "Only first argument to method foo is used" if @_ > 1; $self->{ foo } = shift if @_; $self->{ foo }; } my $x = bless +{}, 'Foo'; $x->foo = 3; print $x->foo, "\n"; $x->foo++; print $x->foo, "\n"; $x->foo += 6; print $x->foo, "\n"; __END__ 3 4 10
      I know that user-defined functions with the lvalue attribute, in general, will give wrong results in the debugger, but that's only a problem for those weenies who use the debugger ;-) (Plus, there are good ways around this.)

      the lowliest monk

        Yeah. The problem with them is one can't check the value before it is set. I would like to have something like
        sub foo : get { my $self = shift; return $self->{_foo}; } sub foo : set { my $self = shift; my $value = shift; die "foo is a integer field!\n" unless $value =~ /[+-]?[0-9]+/; $self->{_foo} = $value; }


        holli, /regexed monk/