in reply to Side Context in an 'lvalue' Subroutine

I think the Want module might be exactly what you're looking for.
HTH

broquaint

  • Comment on Re: Side Context in an 'lvalue' Subroutine

Replies are listed 'Best First'.
Re^2: Side Context in an 'lvalue' Subroutine
by tadman (Prior) on Mar 18, 2002 at 19:21 UTC
    The Want module is quite interesting, but seems a little awkward in terms of implementation. Here's an example:
    use Want; sub fooz : lvalue { defined ($foo_new)? $foo_new : (want('LVALUE','ASSIGN')? $foo_new = $foo : $foo); }
    Internally, there is a function from the Wait.xs component called 'want_lvalue', which is really all I need. If it were assigned a default parameter value (it relates to stack depth) then it could be used like so:
    use Want; sub fooz : lvalue { defined ($foo_new)? $foo_new : want_lvalue? $foo_new = $foo : $foo); }
    This does seem to be a lot neater, though not currently implemented.

    It just goes to show that CPAN has a module for every occasion. I wouldn't be surprised to see Cheese::Grater.

    Thanks for the tip. It's exactly what I was looking for.