MOO-cows Mailing List Archive


Re: List operations (Was: More LPMOO stuff)

Chuck Adams spaketh:
Ben Jackson drew these hieroglyphs:
<> > Hence list[n..] would be equivalent to list[n..length(list)], except it
<> > should save the extra time of evaluating length(list).
<> It would save you the extra time of *typing* length(list).  The length
<> will still have to be evaluated.  In either case it's O(1), since list[0]
<> contains the length (it's inaccessible from MOOcode).  I don't think you
<> can argue that this would be a performance improvement.
< well, it'd shave off a few steps, not having to deal with an explicit
< builtin call, but that already got covered.  just want get my opinion
< out:
< the syntax kind of bugs me.  i can see where it comes from, but it
< does look like a typo.  my preference would be for foo[1..$] as is
< specified in the "to-do" list for the LamdaMOO server.

On another somewhat related note, assuming [1..$] existed, you could then
have the compiler use peep-hole optimization and replace certain things in
the parse tree (such as list[1..length(list)] with list[1..$]).  This isn't
the greatest example of optimizing in this means, but it could happen.

Why am I saying this?  Dunno, it just occured to me :)



Home | Subject Index | Thread Index