Hacker News new | ask | show | jobs
by BruceM 3874 days ago
Dylan (http://opendylan.org/) does that via generic functions / multiple dispatch. The object system in Dylan is derived from CLOS from Common Lisp.

Dylan allows sealing of generic functions to limit extensibility where needed and can use that information (along with other information) to optimize, generate warnings, etc.

    define class <weapon> (<object>) end;
    define class <sword> (<weapon>) end;
    define class <wand> (<weapon>) end;

    define class <person> (<object>) end;
    define class <wizard> (<person>) end;
    define class <warrior> (<person>) end;

    define method wield (who :: <wizard>, what :: <wand>) => ()
      ...
    end;

    define method wield (who :: <warrior>, what :: <sword>) => ()
      ...
    end;