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

:immediate behaviour

5 views
Skip to first unread message

Klaas-Jan Stol

unread,
May 18, 2006, 7:01:13 AM5/18/06
to Perl6 Internals
hi,

if I understand correctly, the :immediate pragma makes the sub which has
this pragma run immediately after parsing (well, at least before running
the program)

Suppose I have this code:

.sub loadstuff :immediate
# load stuff
.end

.sub main
dostuff( )
end
.end

Then, running this code will start running the loadstuff( ) again
(because main doesn't have the :main pragma, and loadstuff() is at the
top of the file).
My concern is, is this the desired effect? Shouldn't the :immediate subs
only be run once? So, in effect shouldn't they be skipped (if they're at
the top of the file, where execution starts when :main is missing) when
running the program?

regards,
klaas-jan


Leopold Toetsch

unread,
May 18, 2006, 12:55:17 PM5/18/06
to Klaas-Jan Stol, Perl6 Internals

On May 18, 2006, at 13:01, Klaas-Jan Stol wrote:

> Then, running this code will start running the loadstuff( ) again
> (because main doesn't have the :main pragma, and loadstuff() is at the
> top of the file).
> My concern is, is this the desired effect?

I dunno, what the desired effect is. But it works now as documented.
There are 2 easy code changes to get your 'desired' effect:
1) label one sub with :main
2) don't emit :immediate as the first sub

leo

Patrick R. Michaud

unread,
May 19, 2006, 10:35:54 AM5/19/06
to Klaas-Jan Stol, Perl6 Internals

I'm a fan of explicitness and orthogonality -- I don't see that
":immediate" should silently imply "and don't use this sub as :main".
If a sub other than the first one listed is main, mark it as ":main"
and be done with it.

Pm

0 new messages