Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^3: Experimenting with Lvalue Subs

by theorbtwo (Prior)
on Jan 25, 2005 at 02:10 UTC ( #424769=note: print w/replies, xml ) Need Help??

in reply to Re^2: Experimenting with Lvalue Subs
in thread Experimenting with Lvalue Subs

As I look more, I begin to see a problem in my plan. It's in the last paragraph of the above, which assumes that we can figure out which of a set of multimethods will be called in any purticular circumstance very early -- it'd require evaluation of the RHS before we determine what context to evaluate the RHS in. It may be neccessary to provide the context of the RHS as an explicit attribute of the method, and disallow having different versions that vary by rvalue context with the same non-rvalue signature.

The order of evaluation would then go as follows:

  1. Invocant.
  2. LHS arguments
  3. At this point, we determine which of the potentially competeing multimethods to call. If there are none, or more then one with the same goodness, error (possibly not error, but just pick the first or last in the second case).
  4. Determine the context for the RHS.
  5. Evalute the RHS.
  6. Finally, call the actual lvalue method.

I realize that this makes reverting the value somewhat more complex from the core -- but if the core thinks of the rollback as being a new assignment, and propigates exceptions thrown, it shouldn't be much more difficult. (Note that this is hardly the only place that exceptions can be thrown from nonobvious places.) I think it's far more important to give an interface to lvalue subs that matches the way people think about them.

Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node). Update: fixed HTML.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://424769]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2017-12-11 22:07 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (314 votes). Check out past polls.