Re: Object Method Question
Hi david,
David Tillman <dtillman_at_ozarkaircraftsystems.com> writes:
> Hello all, I have an object foo that I want to pass various other
> objects, strings, numbers, whatever, to with different behavior.
> That is trivial.
>
> The part I am uncertain about is that I intend to pass it both
> single objects and lists of objects. Suddenly my carefully crafted
> methods fail because the item being passed is neither a bar-object
> not a baz-object - it is a list.
>
IMHO, you should use the builtin multi-method dispatch, such as in
the following where 'test' dispatch on the first parameter :
(define-method test ((a <pair>)) 1) ;; returns 1 for pairs (and lists)
(define-method test ((a <string>)) 2) ;; returns 2 for strings
......
(define-method test (a) 'unknown) ;; returns 'unknown for others
> If you are wondering what I am trying to accomplish, I am reworking
> my stklos-html library. I have never been happy with the Table object
> an I now intend for the (append foo my-table) method to accept TR, TH,
> TD, string and numeric arguments - both atoms and lists.
>
> Thank you for your opinions,
Hope it helps ,
> -Dave
>
Jean-Marie
Received on Mon Jul 16 2001 - 21:30:22 CEST
This archive was generated by hypermail 2.3.0
: Mon Jul 21 2014 - 19:38:59 CEST