[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lambda The Ultimate: use failure-thunk instead of default value?
On Thu, Jul 07, 2005 at 10:58:06AM +0100, Tony Garnock-Jones wrote:
> (hash-table-get valmap id
> (lambda () (error "Object does not contain slot"
> (desc-id-and-slot id slotname))))
I've also thought about this. I know the thunk version is more
expressive. However, I also think that a simple default value is the
common case. I'd like to have both. You propose using (always) or, why
> (define (always something) (lambda () something))
> (hash-table-get *forward-slots* id (always #f))
But it is not so neat and I should probably provide this routine as a
part of this SRFI to prevent people writing it again and again. OTOH,
it does not strictly "belong" into this SRFI. (Maybe somebody should
write a SRFI for combinators?)
Another option would be to treat defaults that satisfy procedure?
specifically. But this might confuse people. It does not make the
construction less expressive, though, as one can give
(hash-table-get ht key (lambda () (lambda ...)))
I'd like to hear more opinions on this.
Another complication is that I posted a final version of the SRFI some
three days ago. I'm not sure what the SRFI process says about this.
> rather than:
> (let* ((*failure* "failure")
> (result (hash-table-get valmap id *failure*)))
> (if (eq? result *failure*)
> (error "Object does not contain slot"
> (desc-id-and-slot id slotname))
"failure" is not even guaranteed to be unique. Rather use something
(define *failure* (list '*failure*))
personal contact: atehwa@xxxxxx, +35841 5323835, +3589 85619369
work contact: pkalliok@xxxxxxxxxxxxxxxx, +35850 3678003
kotisivu (henkkoht): http://www.iki.fi/atehwa/
homepage (technical): http://sange.fi/~atehwa/