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

another deprecated one: newsub?

0 views
Skip to first unread message

Leopold Toetsch

unread,
Oct 3, 2005, 4:00:33 PM10/3/05
to Internals List
1) newsub with 4 arguments

op newsub(in INT, in INT, labelconst INT, labelconst INT)

Creates a 'Sub' in P0 and a 'Continuation' in P1. It was invented as a
speed hack before Sub PMCs and return continuations did exist. The
implicit register usage needs extra code inside IMC. Other arguments
against it are common with the 3-arg newsub.

It should for sure go away.

2) newsub with 3 arguments

op newsub(out PMC, in INT, labelconst INT)

Creates a new 'Sub"-like PMC of given type and label. The opcode is too
general: Sub objects created with this opcode don't have a name and are
missing other meta-information like the end of the subroutine. This
would disable bounds-checking during execution of such an object. Other
meta-information missing from such subs include the namespace, HLL
information, and MMD type information.
The given label doesn't have to be a real .sub label either.

The opcode is not needed IMHO:

.sub foo

or the PASM equivalent

.pcc_sub foo

both create a Sub PMC, which can be looked up or resolved at compile
time, when the sub is in the same comilation unit. If there is really a
need to create a new Sub object, an existing one can be cloned.

.sub gen
...
.yield(res)
...

creates a Coroutine PMC due to the presence of the .yield.

Closures are only reasonably useful, if the closure objects are
distinct. Therefore:

.local pmc clos
clos = find_name "foo"
clos = clone clos

can be used instead of the newsub opcode.

I'm going to deprecate both soon, if there arent' really strong
arguments against it.

leo

0 new messages