[racket] How to use abstract classes?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed Aug 24 11:01:37 EDT 2011

I guess the easiest thing is just to not call 'new' with that as an
argument. If you were worried that someone might do that anyways, then
you could do something like this:

(class object%
  (define/public (die) (error 'myclass "do not instantiate me"))

and insist that subclasses override the 'die' method to do nothing.

If you were doing this a lot, you could abstract this pattern into a macro.


On Wed, Aug 24, 2011 at 9:31 AM, Alexander Kasiukov
<kasiuka at sunysuffolk.edu> wrote:
> Dear Racket users,
> What is the best way to make a class in Racket abstract? I would like to
> have a class which
>    never gets instantiated
>    implements certain methods common to all of its children
>    needs to call some of the methods implemented in the children.
> Sincerely yours,
> Alex
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

Posted on the users mailing list.