Proposal about the "self" keyword

NotFound julian.notfound at gmail.com
Wed Feb 4 20:34:46 UTC 2009


> My proposal is this: All subs get the "self" keyword, whether they
> want it or not. "self" in all subs point to the object that was being
> invoked. In an ordinary subroutine, "self" will refer to the Sub PMC
> itself. Ignore it if you don't want it, and nothing really changes
> from how things are treated now. Objects, when invoked, will have this
> "self" if they want it, which they probably always do. This also is
> going to help us a lot internally, where we can unify the functions
> for calling methods and functions for calling non-method subs. We
> simplify a few things in IMCC too, although we do pay because an extra
> parameter is being passed in many cases where it's not needed. As part
> of this, I may also like to change VTABLE_invoke to take 4 parameters
> instead of 3 (adding an optional invocant PMC, if it's different from
> the sub object being invoked).
>
> What do people think of this proposal? Any immediate problems come to
> mind that would make this a Bad Idea?

I like the idea. It solves the invoke problem, allowing passing
functors where subs are expected, and simplifying the interoperability
with languages where functions are objects.

A <big>+1</big>

-- 
Salu2


More information about the parrot-dev mailing list