Hi, Gregg,

Gregg Irwin wrote:
> 
> ... For example, how would
> we build constructs in REBOL to emulate what Perl does with
> auto-sizing arrays,

Exactly what I was hoping for.  As an example, I've been using the
nested-block trick to simulate mutable arrays in REBOL for some time,
and have no specific problem/complaint with it (other than the fact
that it looks a bit funny... ;-)  However, I was hoping for some
additional suggestions from the list.

 > or what would a Perlite/Perler/Perl-monger (proper
> term?) do to provide protection *against* auto-sizing if it wasn't
> desired.

I can think of three alternatives right off:

     ++$array[$n] if $minOK <= $n && $n <= $maxOK;

to ignore OOBVs (out-of-bounds values),

     ++$array[$n < $minOK ? $minOK : $maxOK < $n ? $maxOK : $n];

to force OOBVs to the violated boundary, or

     ++$array[$minOK <= $n && $n <= $maxOK ? $n : $default];

to force OOBVs to some default bucket.  The last two index expressions
(for those not familiar with C or Perl) are essentially equivalent to
the REBOL expressions

     either n < minOK [minOK] [either maxOK < n [maxOK] [n]]

and

     either all [minOK <= n  n <= maxOK] [n] [default]

I'd actually write the first of these in REBOL as

     max minOK min maxOK n

To say that in Perl one would need to define the min and max functions,
as they aren't built in.

-jn-




-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to