in reply to Re^2: A tale about accessors, lvalues and ties
in thread A tale about accessors, lvalues and ties

Ok, your reference to needing a wrapper to control the setting of the attribute made me think you were talking about direct access. I'm definitely not a fan of lvalue subs or tie. Other than Ruby, are there any languages that support syntax like "object->method = value"?
  • Comment on Re^3: A tale about accessors, lvalues and ties

Replies are listed 'Best First'.
Re^4: A tale about accessors, lvalues and ties
by LanX (Saint) on Nov 19, 2008 at 14:43 UTC
    Perl 6 ! ; )
    my sub thingie is rw { return my $var is Proxy( for => $hidden_var, FETCH => { ... }, STORE => { ... }, TEMP => { ... }, ... ); }
    see Apocalypse 6

    But I'm not sure if it is really faster than what we already have in modules like Contextual::Return.

    Depends on how fast ties are realised in p6...

    Cheers LanX
Re^4: A tale about accessors, lvalues and ties
by LanX (Saint) on Nov 19, 2008 at 10:15 UTC
    > Other than Ruby, are there any languages that support syntax like "object->method = value"?

    Python does via so called properties. But I don't know any implementation or performance details.

    This way simple attributes can be easily turned into mutators without any need to change the API.

    > I'm definitely not a fan of lvalue subs or tie.

    OK, it seems overcomplicated to do it this way. But IMHO it's stable, has no side-effects and can be hidden behind a nice syntax. It's just slow!

    Look, I don't know every archive discussion, so I'm relying on PBP. ... But the reasoning "Don't use lvalue-attributes because you will be forced to use tie afterwards and we showed you earlier that tie is evil" is shallow.

    All "earlier arguments" against tie in PBP do not apply with lvalues, except the slowness!

    So tuning up tie would solve the whole thing. I mean an alternativ static version hooking wrapper-method directly to variables.

    Or does anyone have a good example, where tie profited from resolving methods dynamically and having inheritance and overload and the other OO stuff?

    Cheers LanX

Re^4: A tale about accessors, lvalues and ties
by holli (Abbot) on Nov 19, 2008 at 13:40 UTC
    .NET


    holli, /regexed monk/