[Prev][Next][Index][Thread]

Re: Interfaces




Neel Krishnaswami wrote in message ...

>ISTM you can get most of the way there with modules already.
>
>Do something like
>
>  define module foo-interface
>     create
>       bar, baz;
>  end module;
>
>To implement the interface, define a new module that uses the
>interface:
>
>  define module foo-implementation
>    use foo-interface, export: all;
>  end module;
>
>And then if you don't implement both bar and baz in the module
>foo-implementation, then you get a compile time error. You can
>implement as much of the default protocol as necessary in
>foo-interface, too.
>
>I think the only thing Dylan really needs to make this a complete
>solution is a way to parametrize modules, a la Standard ML's system of
>functors. (Matthias Felleisen's units system for DrScheme might also
>be worth stealing^H^H^Hlooking at, since it's basically functors for
>dynamically typed languages.)
>
>If you want to add types to the interfaces, then I think you'd have to
>add parametric types (like Cecil, Eiffel, or GJ) to keep the interface
>from becoming a stratjacket that blocks reuse.


That's quite clever!  Good one!

But the reason I don't like it, is that it's not really first class.
Dylan modules are compile-time objects, and you can't ask
anything about them at run-time.  That is, you can ask a class
what methods or superclasses it has.  You can ask a G.F.
what methods it has.  But you can't ask this sort of an interface
what GFs are in it.  I think this sort of introspection could be
useful in a number of ways in real-worl applications.

(But I still think your idea is clever.)





Follow-Ups: References: