At 01:03 PM 9/24/2001 -0400, Michael Maraist wrote:

> > > is it possible the ops to handle variable number of arguments, what I 
> have
> > > in mind :
> > >
> > > print I1,",",N2,"\n"
> >
> > This should be done by create array opcode plus print array opcode.
> >
> > [1, 2, 3, 4, 5]
>
>I have a minor issue with a proliferation of createArray.  In perl5 we
>used the Stack for just about everything minus physically setting @x =
>(1,2,3).  The creation of a dynamic array is a memory hog.

Less of a hog in many ways than using a stack. Worth the times when it's not.

>ESPECIALLY with
>mark-and-sweep dynamic memory (which is sounds like perl6 is aiming for).

I don't see the connection here.

>Lets say you wanted
>for(...) {
>   x++
>   y++
>   z++
>   print "x=$x, y=$y, z=$z"
>}
>Then you'd possibly have
>
>LOOP: cond_eq Ix, DONE
>inc I1, 1
>inc I2, 1
>inc I3, 1
>createArray P1, 6
>setIndexOf P1, 0, "x="
>setIndexOf P1, 1, I1
>setIndexOf P1, 2, ", y="
>setIndexOf P1, 3, I2
>setIndexOf P1, 4, ", z="
>setIndexOf P1, 5, I3
>print P1
>branch LOOP
>DONE:

If the compiler generates code like that and I'm happy about it, someone 
needs to smack me. *hard*. :)

That ought to be either a series of print ops or, more likely, a set of 
push ops and a final prints.

>In any case, what we've done here is dynamically create an array each time
>through the loop.

Yes, but we're doing this with a stack-based system anyway. It's just an 
anonymous pesudo-array (i.e. the stack top), but an array nonetheless.


                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to