This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
On 3 Nov 1998, Harvey J. Stein wrote: > Jay Glascoe <jglascoe@jay.giss.nasa.gov> writes: > > > But... what's the point? That's essentially what make-dictionary and > > friends are doing now. > > This is exactly what I was thinking of. The points would be that a) > it's 1 fcn instead of 3 fcns & b) it allows user supplied equality & > hashers. They'll be necessary in certain applications & if the user > really needs it & needs it to be fast he'll compile the fcns & link > them in. > okay, done! But I'll keep "make-dictionary", "make-dictionaryv", and "make-dictionaryq" (just to spite you, Harvey ;) and I'll add: primitive: make-dictionaryx [equality-predicate] [hasher-function] "equality-predicate" defaults to 'equal? as per your suggestion: if "equality-function" is one of 'equal?, 'eqv?, eq? then hasher-function defaults to 'my-hasher, 'my-hasherv, 'my-hasherq respectively. Else, both "equality-function" and "hasher-function" must be provided. One caveat: both arguments must be symbols bound to procedures or primitives available to the current scope. So, e.g. (make-dictionaryx (lambda (x y) (eq? x y)) (lambda (x) (hashq x))) is a double no-no. This way I can still maintain the whole "read"/"write" thing. Dictionaries will now look like, e.g. (#(equal? my-hasher 351 #t #t) . #(bucket1 bucket2 ... bucket2^m)) (#(fave-eq? fave-eq-hasher 723 #t #f) . #(bucket1 bucket2 ... bucket2^n)) > -- > Harvey J. Stein > BFM Financial Research > hjstein@bfr.co.il > Jay jglascoe@jay.giss.nasa.gov