[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: <boolean> (was Re: object-class)
- To: dyer@eagle.sharebase.com (Scot Dyer)
- Subject: Re: <boolean> (was Re: object-class)
- From: Bob Kerns <rwk@crl.dec.com>
- Date: Sun, 22 Nov 92 00:33:13 -0500
- Cc: eliot@dcs.qmw.ac.uk, info-dylan@cambridge.apple.com
- In-reply-to: Your message of "Sat, 21 Nov 92 15:35:16 PST." <9211212335.AA08608@eagle.sharebase.com>
Date: Sat, 21 Nov 92 15:35:16 PST
From: dyer@eagle.sharebase.com (Scot Dyer)
/// I don't have the DYLAN book to hand so I won't embarrass myself trying
/// to translate. DYLAN equivalents anyone?
This can't be properly translated to Dylan (I don't think) since Dylan has no
proper way of specifying lazy evaluation of arguments to functions. In fact,
adding this to Dylan would be highly nontrivial since it would require a _lot_
of typing info (which may not be availible) in order to do the dispatch right.
Please forgive any syntactic errors, since I'm at home
without my Dylan manual, and Scheme is not my native
language, but:
(if cond true false) =>
(define-method my-if ((singleton #t) then else)
(then))
(define-method my-if ((singleton #f) then else)
(else))
(my-if cond (lambda () then) (lambda () else))
I agree that this is not an optimal solution for an OOPL to take, but pattern
matching is _very_ expensive. For example, in the current spec, I cannot
specialize on a parameter to a method such that the method will be invoked for
parameters that are general instances of some class C only when some slot of
that class has a particular value. In other words, I can specialize on value
_or_ on class, but not on a combination of the two.
You can do this in two stages:
(define frobulate (frob)
(frobulate-on-slot frob (frob-impellor frob)))
(define-method frobulate-on-slot ((frob hairy-frob) (impellor neoprene))
(frobulate-thoroughly frob impellor))
This is easy enough, that I do not see it as a major issue.
It's just too hard for the language to embody the entire range
of things you might want to specialize on. It's better to let
the programmer take over this, and not hair up the language.