automagic "self"

Jonathan "Duke" Leto jonathan at leto.net
Sat Feb 4 22:54:49 UTC 2012


+1 to demagicification of self params

On Sat, Feb 4, 2012 at 12:40 PM, Andrew Whitworth <wknight8111 at gmail.com> wrote:
> The "self" variable in PIR is extremely magic. If you mark the .sub
> with the :method flag, IMCC will automatically add a parameter to the
> front of the list of parameters called "self". IF you do not use the
> :method flag, but use the "self" variable in a .sub without declaring
> it first, IMCC will also helpfully automatically and invisibly insert
> "self" at the front of the list of parameters.
>
> I would like to end this behavior. At the PIR level, I think that
> "self" should have to be manually specified with a ".param"
> declaration or equivalent. At the NQP and Winxed level, of course,
> user-visible behavior does not need to change. Any languages using a
> custom parameter binding (e.g. Rakudo) would also likely remain
> completely unmodified.
>
> Assuming there are no major complaints, I would like to start a branch
> to work on this issue soon. The first step would be to add behavior to
> IMCC that if the first .param is named "self" we don't automatically
> prepend another self variable to the front of the list. As an example,
> currently this throws a runtime error about not having enough
> parameters passed, but does not throw a compile-time error about a
> "self" parameter being defined twice:
>
> .sub foo :method
> .param pmc self
> say self
> .end
>
> The second step of the switch would be to remove automatic "self"
> magic and fix whatever errors pop up from that.
>
> This is a nit that we've discussed in the past, and decided previously
> that it wasn't worth the energy to fix. However, now this is standing
> in the way of some real improvements to PCC and IMCC and I would like
> to work on dealing with it now.
>
> I would love to hear what other people think. Thanks.
>
> --Andrew Whitworth
> _______________________________________________
> http://lists.parrot.org/mailman/listinfo/parrot-dev



-- 
Jonathan "Duke" Leto <jonathan at leto.net>
Leto Labs LLC
209.691.DUKE // http://labs.leto.net
NOTE: Personal email is only checked twice a day at 10am/2pm PST,
please call/text for time-sensitive matters.


More information about the parrot-dev mailing list