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

Re: [Q] Dylan to Java/JVM compiler?



On Tue, May 8, 2001, Lieven Marchand <mal@wyrd.be> wrote:

>But what's the use of an abstract interface if only one implementation
>can exist? Suppose I want <my-implementation> to also implement
><interface>. Do I write a make-my-implementation?

Insulating client code from having to instantiate the correct one. Simple
example: make <button> might return <win32-button> or <motif-button>. Of
course that's kind of a bad example, since one could do that with macros
at compile time. But there can be situations where it is useful to have
the decision of what concrete class to return made at runtime, without
the client class having to know the details. Note that the former example
could easily be extended to:

define method make (class == <interface>, #key, #rest initargs )
  if (*moon-is-full*)
    apply (make, <scary-implementation>, initargs);
  else
    apply (make, <normal-implementation>, initargs);
  end if;
end method;


Scott Ribe
scott_ribe@killerbytes.com
http://www.killerbytes.com/
(303) 665-7007 voice



Follow-Ups: References: