REBOL 3.0

Series ordinals now behave like PICK

Carl Sassenrath, CTO
REBOL Technologies
9-Apr-2006 21:59 GMT

Article #0008
Main page || Index || Prior Article [0007] || Next Article [0009] || 21 Comments || Send feedback

The series ordinals (first, second, etc.) were originally designed to be more strict - mainly for beginner usage. For example:

print first tail "abc"
** Script Error: Out of range or past end

causes an error. However, the pick function does not:

print pick tail "abc" 1
none

I used to think this difference was ok because experts did not use first. However, I no longer believe that. The ordinals are very efficient functions, and I tend to find myself using them as fast selectors with code like this:

the-name: :first
the-email: :second
the-message: :third

send the-email data the-message data

For high performance code, this method is as fast as you can get. When used in high-speed loops, it is much faster than using object field selectors (those require both path interpretation and run-time selector binding). In fact, I use this method so often that I've implemented an ordain function for defining the above ordinal relationships in my code.

There is only one problem. The "past end" exception is no longer desireable.

In REBOL 3.0 changes in the implementation of the ordinals (from datatype-specific action functions to generic abstract native trampolines) made them by default work like pick (what the trampolines actually call). The past-end error is now gone.

This seems preferable, and the change should be compatible because the past-end usage case was an exception in prior versions, so is not utilized in existing code.

Note that this will require some minor documentation updates.

21 Comments

REBOL 3.0
Updated 30-Apr-2017 - Edit - Copyright REBOL Technologies - REBOL.net