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

Re: Can one do the following in dylan?



On Wed, 28 Mar 2001, Samuele Pedroni wrote:
> Thanks for all the answers.
> 
> If I have well understood in dylan one can do the following:
> 
> - define a framework as a (shared?) library with an 'open' base class and
> related methods and an 'open'
>    generic factory function
> - compile the main program against the framework and have it load further dlls
> in some os
>     specfic manner (this works with Fun-O at least) and call the factory
> function with the "right" param.
> - indipendently write and  compile the plug-ins/servlets/etc against the
> framework and define
>    more specific versions of the factory function (e.g. dispactching on
> singleton strings) and the needed
>    sub-classes
> 
> run the main program with an indication of which dlls should be loaded and with
> wich parm the generic
> factory function should be invoked.

Yes, and of course you could get the "indication of which ..." after you
launch the program.

Regarding the "factory function" you mention: given that "make" is for
exactly this purpose, you may find you can do what you want as follows.
This way you don't have to write more than one method for make-plugin and
probably can just implement class-for-plugin-name as simple lookup,
rather than a load of almost-identical methods.

define method make-plugin
    (name :: <string> /* or <symbol> ? */,
     #rest args)
 => (instance-of-named-plugin)
  let new-class = class-for-plugin-name("foo"); // or #"foo" ?
  apply(make, new-class, rest)
end;

You can even get the arguments for the class at runtime, possibly
involving converting the 1st, 3rd etc. to <symbol>.

> PS:  this will  currently not work with Gwydion Dylan: correct?

AFAIK, that's correct (though I'm not really a Gwydion user).

HTH,
Hugh




References: