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

Re: Can one do the following in dylan?



In article <3AC0C8D1.ED20B44C@inf.ethz.ch>, Samuele Pedroni 
<pedroni@inf.ethz.ch> wrote:

> [the motivation of this mail is really intellectual curiousity, not to
> start a flamewar, java
> is not my language-of-choice, I have not such a thing]
> 
> In java the following is possible:
> 
> <Plugin.java>
> public interface Plugin{
> 
>   public void init();
> 
>   public Object do(Object action);
> 
> }
> </Plugin.java>
> 
> <Foo.java>
>  ...
>   Plugin plugin = (Plugin)Class.forName(pluginName).newInstance();
>   // pluginName is the "name"  of a up to runtime unknown and separately
> compiled class
>   // implementing the Plugin interface
>  ...
> </Foo.java>
> 
> Is something like that (*language-aware* dynamic loading, no C low-level
> shared library stuff)
> possible in dylan? (AFAIK no but ...)

You can't do it from a textual name.

But if you have dynamically loadable libraries then the init code in 
those libraries should be adding appropriate methods to appropriate open 
generic functions, including methods on "make()".  So if you then get 
hold of a reference to a class object from that library -- perhaps as 
the result of calling some function in that class -- then the client 
code can happily create instances of that class.

-- Bruce



Follow-Ups: References: