Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[CVS ci] NCI sub call syntax in PIR

3 views
Skip to first unread message

Leopold Toetsch

unread,
May 6, 2004, 3:12:24 AM5/6/04
to Perl 6 Internals
A bit less typing for NCI calls:

1) declare the pmc type as NCI

.local NCI the_sub
# get it from somewhere e.g.:
# the_sub = global "ncurses::initscr"

2) just call it:

r = the_sub(args)

Works only for named subs of course.

This saves a savetop/restoretop pair and creating a return continuation,
because a plain "invoke" is emitted for the function call.

t/pmc/nci.t has an example too

Have fun,
leo

Dan Sugalski

unread,
May 6, 2004, 12:45:56 PM5/6/04
to Leopold Toetsch, Perl 6 Internals
At 9:12 AM +0200 5/6/04, Leopold Toetsch wrote:
>A bit less typing for NCI calls:
>
>1) declare the pmc type as NCI
>
> .local NCI the_sub
> # get it from somewhere e.g.:
> # the_sub = global "ncurses::initscr"
>
>2) just call it:
>
> r = the_sub(args)
>
>Works only for named subs of course.
>
>This saves a savetop/restoretop pair and creating a return
>continuation, because a plain "invoke" is emitted for the function
>call.

I'm pretty sure this isn't a good idea, unless we want to introduce a
number of enforced safety constructs. (Mainly PMC immutability,
namespace slots that can't be layered over, and namespace slots that
can't be changed) Someone may choose to swap out the PMC for a sub to
do any number of things, some of them even reasonable. (Mostly
wrapping them, but there are others, I expect)
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

0 new messages