Previous chapter: #27: Pseudo-Generic Mappers (Change)
Dylan Design Notes
Dylan Design Notes: #28: First, Second, Third are Functions (Change)
#28: First, Second, Third are Functions (Change)
Version 1, January 1994
Copyright (c) 1993-1994, Apple Computer
The functions first, second, third, and their associated setter functions
are specified as generic functions on sequences. This design note
changes them to functions.
Change the following functions currently documented as generic functions
to instead be functions with the indicated definitions:
first sequence #key default => value
second sequence #key default => value
third sequence #key default => value
Each of these functions returns the indicated element of the sequence, by
calling element with the supplied arguments and the corresponding index.
first-setter sequence new-value => new-value
second-setter sequence new-value => new-value
third-setter sequence new-value => new-value
Each of these functions sets the indicated element of the sequence and
returns the new value, by calling element-setter with the supplied
arguments and the corresponding index.
Notes
The functions first, second, third, and their associated setter functions
are specified as generic functions on sequences. It would be a serious
problem if any of them should differ from a call to element or
element-setter (as appropriate) with the corresponding integer key. The
existence of these functions without any specified methods makes it
difficult for programmers to know whether they need to explicitly define
additional methods for these functions that are applicable to new
sequence classes.
Next chapter: #29: For Loops (Change)