This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Trouble understanding define (!)
- To: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Subject: Re: Trouble understanding define (!)
- From: Jost Boekemeier <jostobfe at linux dot zrz dot TU-Berlin dot DE>
- Date: 02 Feb 2000 16:55:24 +0100
- Cc: guile at sourceware dot cygnus dot com
- References: <200001142054.UAA00622@ossau> <p2tzou4o5ov.fsf@pampelmuse.zrz.tu-berlin.de> <200001182250.WAA00624@ossau> <xy7ya9nezzz.fsf@mdj.nada.kth.se> <200001221200.MAA00478@ossau> <xy7bt6e82ru.fsf@mdj.nada.kth.se> <s3zotxrqoz.fsf@verisity.com> <xy7iu0cbc1z.fsf@mdj.nada.kth.se> <s3iu0bq1x5.fsf@verisity.com> <xy71z6z35os.fsf@mdj.nada.kth.se> <s33drfpm9d.fsf@verisity.com> <xy73drec8ap.fsf@mdj.nada.kth.se> <p2t66w7j24a.fsf@guave.zrz.tu-berlin.de> <xy7r9evvo1v.fsf@mdj.nada.kth.se> <p2t3drbj09i.fsf@guave.zrz.tu-berlin.de>
>>> You have a module "draw" which exports several names:
>>> draw<int>...
>>> draw<grapics><line>...
>>> draw<grapics><point>...
>>> draw<cards><field>...
>>> draw<cards><card>...
>> The modules are "graphics" and "cards". The name being exported is
>> "draw".
>Yes. But what if we handle classes as modules? A GF would be a
>module and a class with its data structure would be a module. Et
>voila...
More precisely: The names being exported from module "draw" are <int>,
<graphics><line>, <graphics><point> ... Of course, they are invisible
to users.
[I wrote:]
> ML´s parametric modules are just another word for "generics": They
> dispatch on their arguments (only one in ML) and produce a concrete
> value (the concrete module in this case).
Here's what generics do (short form: M[P_1,...P_n] -> V):
1 $n$
M ----> C 1
(uses) ^
|
P $n$
Example:
signature SYMBOL = sig [...] end;
signature SYNTAX = sig structure Symbol: SYMBOL [...] end;
functor MakeSymbol(): SYMBOL = struct [...] end;
functor MakeSyntax(Symbol: SYMBOL): SYNTAX =
struct
structure Symbol: SYMBOL = Symbol
[...]
end;
structure Symbol: SYMBOL = MakeSymbol();
structure Syntax: SYNTAX = MakeSyntax(Symbol);
In the above example C is SYMBOL, P is Symbol and M is Syntax.
If you declare function prototyps in SYMBOL's interface, the concrete
methods in each of the Symbol implementations and let Syntax call
these functions, you have multiple dispatch. You can think of SYMBOL
as the GF, $n$ concrete implementations (Symbol) and the container
(Syntax) which uses them.
Jost