Index - All Packages - All Categories - All Classes

Class Pair

Sometimes you just want to pass around two things where the language only makes it convenient to pass around one. I know that the proper object-oriented (or even "structured") thing to do would be to create a type specific to the particular kind of pair which is being used for a particular purpose. However, sometimes it just seems like too much trouble. By using Pairs, we import the sins of Lisp. At least we don't have RPLACA and RPLACD. Unlike Lisp's cons cell's "car" and "cdr", we call our two parts the "left" part and the "right" part. "pair(a,b)->left()" yields a and "pair(a,b)->right()" yields b.

Give us feedback: Should Pairs be removed? Do you know of any justification for them other than a bad simulation of "multiple-return-values" (as in Common Lisp, Forth, Postscript)?

The Pair code is currently in a state of transition. Old code (which we have yet to fix) uses Pairs with nils in their parts. Pairs will be changed to outlaw this usage. "fetchLeft" and "fetchRight" exist to support this obsolete usage, but will be retired. Don't use them.

Package: Udanax-Gold
All Superclasses: Object Heaper
Protocols: Object
Categories: Xanadu-Collection-Tables

Class Methods

make: left with: right


pairWithNils: left with: right

Create a new pair. Either may be nil in order to support broken old code.

Instance Methods

actualHashForEqual


create: a

create a new pair

create: a with: b

create a new pair

createRcvr: receiver


fetchLeft

Returns the left part which obsoletely may be nil

fetchRight

Returns the right part which obsoletely may be nil

inspectPieces

Return pieces to be used in a tree browser.

isEqual: other


left

Returns the left part. Lispers may think 'car'.

printOn: oo



Overrides: Object

reversed

Returns a new pair which is the left-right reversal of me.
pair(a,b)->reversed() is the same as pair(b,a).

Only works on non-obsolete Pairs--those whose parts are non-nil

right

Returns the right part. Lispers may think 'cdr'.

sendSelfTo: xmtr




Index - All Packages - All Categories - All Classes