> The solution that springs to mind is to choose which class to instantiate
> with (if (list? param-a) ,,,) but then I'd have to state the parameter lists
> twice.

Hi Kieron,


Can you choose the class using an if or cond?

For example:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (try-it x)

  (define the-class%
    (if (list? x) multi-item-representer% item-representer%))

  (define r (new the-class% [param-a x] [param-b 50] [param-c "yellow"]))

  (send r print))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

This bit of code binds the-class% at runtime to one of those classes,
depending on x.
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to