Multimethods in a latently typed language?

(I posted this initially to comp.lang.misc and was told to try here instead)

I'm implementing a vaguely scheme-like scripting language and I'm a
unclear on how to make multimethods work (not just within an object
system, but with all the language types). Are "types" just symbols or
do they require their own namespace?

(defun f ( (x 'int) (y 'string)) (...code))
(defun f ( (x (resolve-type int)) (y (resolve-type string)) ) (...code))

Should I combine the concept of class and and type? This seems
problematic since I want objects to be runtime-modifiable (add/remove
methods). I was also considering making predicate types as the basis
for method resolution (obj has_method x, etc..), but then how do I fit
in primitive types?

I guess I'm a bit overwhelmed with type systems and would appreciate
some direction.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Various designs are possible

...but I wouldn't (and didn't) do it like you are proposing. Types need not to be symbols, and they don't need a separate namespace. Types are just objects, and they can use the standard namespace. For example int might be a type; not 'int, and not (resolve-type int).

(In my language types are named with all capitals by convention, because a type is often associated with a constructor function which wants a similar name. But it's just a convention.)

Look at Dylan

Maybe you should look at the Dylan programming language. It supports multi-methods and originally had a Scheme-like syntax.

or eh common lisp..

or eh common lisp..

Scheme Object Systems

Yah, CLOS works too. :$

Here are some links to some Scheme Object Systems. The CLOS-based ones at least support multimethods:


There's also Goo, which is based on multimethods and still has a Scheme-like syntax.