Michal Wallace wrote:
> Benjamin Goldberg wrote:
> > Michal Wallace wrote:
[snip]
> > Also... why is $P2 merely an imcc temporary, without a real name? 
> > That is, why not do:
> >
> > .pcc_sub _sub1 non_prototyped
> >     .local object sub1
> >     find_lex sub1, 'g'
> >     .pcc_begin non_prototyped
> >     .pcc_call sub1, P1
> >     .pcc_end
> > .end
> >
> > The more different prefixes you use ("res", "sub", "$P"), the lower
> > the numbers you'll need to append to them to make the names unique. 
> > Not to mention, it'll make the generated code more meaningful.
> >
> > Another advantage is that with '.local' names, if you accidentally use
> > a name declared in one subroutine, in another, imcc will consider this
> > to be an error.  Such a mistake might be otherwise difficult to spot.
> 
> Hmmm. The counters are global so there shouldn't be any conflicts.
> I'd actually been trying to move away from .local now that I started
> using lexicals... If there's going to be two sets of names for
> everything I'd rather one of them was just $Pxx...

Ehh, why would there be two sets of names for everything?  You mean, one
of them the name to lookup in the pad, the other the imcc name of the
register to use?  There's no reason not to use the same name for both.

(Except that using a unique .local name is still good for preventing
accidental leakage of a name from one sub to another)

> Now, if I could say:
> 
>   .lexical g
> 
> That would be really nice... :)

This is where .macro comes in handy :)

   .macro lexical(name_in_pad, register_name)
      local .register_name
      find_lex .register_name, .name_in_pad
   .endm

And in pirate.py, you'd do:
   self.append('.lexical "%s" %s', lexname, lexname)

Ok, so it's not *quite* what you were asking for, but it's close enough,
eh? :)

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "[EMAIL PROTECTED]
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}

Reply via email to