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

Maybe a misunderstanding, this discussion is intended for those who prefer the flexibility of accessors and are in favour of the neat syntax of lvalues.

Me, I certainly don't want to get into any direct access discussion.

Cheers LanX

- - - - - Which song???

UPDATE: I suppose with "direct access" something like $obj->{attr} is meant.

UPDATE2: Anyway I already studied this Experimenting with Lvalue Subs, but couldn't find a discussion about speeding up tie, only about reimplementing lvalues.

UPDATE3: Let's try to collect some threads:

... to be expanded

searchquery: ?node_id=3989;BIT=%27%20lvalue%20%27%20tie%20%27;BIS=%20%27

  • Comment on Re^2: A tale about accessors, lvalues and ties

Replies are listed 'Best First'.
Re^3: A tale about accessors, lvalues and ties
by perrin (Chancellor) on Nov 19, 2008 at 06:10 UTC
    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"?
      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
      > 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

      .NET


      holli, /regexed monk/