[Prev][Next][Index][Thread]
Re: [Q] Dylan to Java/JVM compiler?
Scott Ribe wrote:
> 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
This of course wouldn't be very convenient. A simple answer is that you write
exactly the same
method using <my-implementation> in the body. Whoever is loaded last wins,
i.e. only one implementation
can be active at a time (look also at the previous discussion about loading
dlls at run time).
Roman
- Warning
- Could not process part with given Content-Type:
text/x-vcard; charset=us-ascii; name="Roman.Budzianowski.vcf"
References: