in reply to (MeowChow) Re6: Comprehending Binary :=
in thread Comprehending Binary :=

No, we're not just saving keystrokes here. We're saving repeated calls to the lvalue method. And, even though method calls in Perl 6 will be faster, not doing any calls in the loop is still a real saving if the loop iterates many times.

Damian

  • Comment on Re: (MeowChow) Re6: Comprehending Binary :=

Replies are listed 'Best First'.
(MeowChow) Re8: Comprehending Binary :=
by MeowChow (Vicar) on Oct 08, 2001 at 08:16 UTC
    So at what point does the lvalue method get called, once $thresh goes out of scope, or once the object is accessed, or at some other time?
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print
      If I understand correctly, you can think of it as roughly akin to a lexical glob assignment. So the lvaluable (lvalued?) method is called on each assignment to $thresh. The moon stays the same, but there are several fingers, each with a different name.
        Good guess. But wrong.

        The method gets called when the binding is first done. At that point the $thresh variable is bound to the lvalue returned by the method call. Thereafter any assignment to $thresh assigns the the original lvalue, which has the effect of assigning to the result of the method call, but without the cost of the method call.