Jonathan Scott Duff wrote:
> 
> I'm fiddling around with parrot and created a getopt macro (inspired
> by the arg processing in Leon Brocard's uniq.pasm :-).  This is my
> first attempt at something semi-useful in parrot.
> 
> Anyway, here it is and looking for comments,
[snip]
> # Note:  Both P15 and I15 are clobbered by this routine. P15 will be a
> #        PerlHash containing the options and their values and I15 will
> #        contain the index of the first non-option arguement on the
> #        comamnd line.
> 
> .macro getopt (str)

Wouldn't it be more flexible to write it as:

   .macro getopt(str, args_in, argout_index, argout_hash)

, so that the user can fully specify where args get read from, and what
gets clobbered?

>         save S0                 # Current command line arg
>         save S1                 # option char
>         save S2                 # scratch string

AFAIK, a single "pushs" op is faster than three "save S<N>" ops.

-- 
$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