On Tue, Nov 01, 2005 at 11:48:34AM +0000, Nicholas Clark wrote:
> On Tue, Nov 01, 2005 at 01:45:10AM -0600, Patrick R. Michaud wrote:
> 
> > but I'm not a fan of writing the $S0 variables -- they seem to distract
> > the code.  I may just go with something like
> > 
> >     code .=    "    lastpos = length target"
> >     code .=    "    gpad = new PerlArray"
> >     code .=    "    rcache = new PerlHash"
> >     code .=    "    captscope = mob"
> >     emit(code, "    bsr %s", label)
> > 
> > which at least changes the first four to be parrot ops instead
> > of function calls for each.
> 
> If this is the code that you're generating, what stops your code generator
> from doing the concatenation itself, and generating an "unreadably" long
> line?

Hmmm, I'm not sure I understand the question here, but since my
original example was incorrect (missing newlines) I'll try again...  
I could do

    .local pmc code
    code = new String
    ...
    code .=    "    lastpos = length target\n"
    code .=    "    gpad = new PerlArray\n"
    code .=    "    rcache = new PerlHash\n"
    code .=    "    captscope = mob\n"
    emit(code, "    bsr %s", label)

Lines like the above are written directly into PGE itself (in PGE/Exp.pir),
are the lines that do the generating (as opposed to being code that
is generated...).  Writing all of those \n's is a bit of a pain to
type, but I guess I can do so at some point.  Or maybe I'll just go
with a string+heredoc syntax for long sequences of code, and leave
the individual emit calls for shorter ones.

Thanks,

Pm

Reply via email to