Browse thread
Renaming structures during inclusions?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Andreas Rossberg <rossberg@p...> |
| Subject: | Re: [Caml-list] Renaming structures during inclusions? |
Christophe TROESTLER wrote: > > Wouldn't it be better to have a compiler switch (say "-w T/t", off by > default) to overide that behavior (new definitions override old ones > as with [open])? Of course that makes it impossible to write M1 > signature without aliasing [t] and [Std] but IMHO that's fine. Note that OCaml's type system fundamentally relies on the fact that type names cannot be shadowed in structures. > This > way, no new syntax needs to be introduced (and one is not forced to > alias modules one does not care about -- e.g. utilities). > > module M = struct > include M1 > type m1_t = M1.t > module M1Std = M1.Std > > include M2 > type m2_t = M2.t > module M2Std = M2.Std > > module Std = struct > include M1.Std > include M2.Std > end > end While your proposal probably could be made to work in this particular case - the compiler had to figure out that it can break the dependency on the first t by reordering m1_t relative to the fields from M1 in the derived signature and substituting m1_t for t in these fields, likewise for the other elements - it is *far* from obvious if and how this can be inferred in general, particularly when your modules go higher-order. I believe it would require something akin to join and meet operations on signatures, but it is known that these don't exist for some very similar systems (signatures for higher-order modules don't form a lattice). Cheers, - Andreas -- Andreas Rossberg, rossberg@ps.uni-sb.de Let's get rid of those possible thingies! -- TB