Previous chapter: #17: Define Like Bind (Addition)

Dylan Design Notes: #18: Member? Intersection Test Arg (Clarification)

Dylan Design Notes

#18: Member? Intersection Test Arg (Clarification)

Version 1, March 1993

This design note clarifies that the <range> methods for member? and intersection support a test: keyword argument, which defaults to id?. This makes the <range> methods consistent with the definitions for these generic functions.


Replace the definition of member? on page 118 with the following:

member? val range #key test => boolean        [G. F. Method]
member? generally terminates when given a range value, even if range is unbounded. However, if range is unbounded, this method is guaranteed to terminate only if test is id? (the default).

Replace the definition of intersection on page 119 with the following:

intersection range1 range2 #key test => range        [G. F. Method]
intersection applied to two ranges and a test of id? (the default) will produce a range as the result, even though the class-for-copy of a range is not <range>. If either range1 or range2 is unbounded, this method is guaranteed to terminate only if the test is id?.


Examples:

? (member? 1 (range from: 0.0 up-to: 10.0 by: .5) test: =)
#t
? (intersection (range from: -5 up-to 10)
                (range from: 1.0 up-to 15.0)
                test: =)
{range 1 2 3 4 5 6 7 8 9}
The return value contains integers in the second example because the elements are taken from the first argument to intersection. This is consistent with the definition of intersection on page 107 of the Dylan manual.

Next chapter: #19: Definitions are Declarative (Change)