[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CLOS vs FLAVORS questions

    Date: Wed, 29 Jan 1992 20:35 PST
    From: Barry Margolin <barmar@Think.COM>

    Disclaimer: I haven't actually done any nontrivial CLOS programming.

       Date: Wed, 29 Jan 92 17:37:03 PST
       From: jbarnett@charming.nrtc.northrop.com

       Are CLOS programmers really able to use the dispatch-on-multiple-args
       capability effectively?  Does EQL dispatching get used in nontrivial
       ways (same argument specialized sometimes by class, sometimes by a
       symbol, etc.)?

    I've been told that people use this to optimize some special cases.  For
    instance, one might write:

    (defmethod plus ((x number) (y number))
      (+ x y))

    (defmethod plus ((x number) (y (eql 0)))

    (defmethod plus ((x (eql 0)) (y number))

    (defmethod plus ((x (eql 0)) (y (eql 0)))

I don't believe code like this will actually result in a speed improvement.
It's more likely to be used to dispose of inconventient special cases, and
to allow distributed specification of case handlers.