RE: additions to standard library?

From: Manuel Fahndrich (maf@microsoft.com)
Date: Fri Mar 10 2000 - 18:55:14 MET

  • Next message: Manuel Fahndrich: "RE: Interpreter vs hardware threads"

    The issue you are raising is a good one. SML/NJ can handle some of it,
    because the semantics of "open" are different there. Once can actually say:

            module Foo = struct
            open B
          end

    and obtain a copy of B within Foo.

    This might even work to extend functors as in:

            functor Foo(Arg : A) =
            struct
               module B = Bar(A)
               open B
               let extensions = ...
            end

    However, this interpretation of "open" has impacts on compilation
    dependencies, in particular scoping analysis (See e.g. "Dependency analysis
    for Standard ML; Matthias Blume; ACM Trans. Program. Lang. Syst. 21, 4 (Jul.
    1999), Pages 790 - 812").

    -Manuel

    -----Original Message-----
    From: Markus Mottl [mailto:mottl@miss.wu-wien.ac.at]
    Sent: Friday, March 10, 2000 12:04 AM
    To: caml-redistribution@pauillac.inria.fr
    Cc: caml-list@inria.fr
    Subject: Re: additions to standard library?

    > But when using functorial interfaces like Set.Make, you have to
    > redefine these functions for each application of the functor. Thus,
    > you really need these functions to be defined in the functor i.e.
    > together with the datatype (and, by the way, you can then define these
    > functions a bit more efficiently---without using exceptions).

    Exactly - this raises another question which has been bothering me from
    time to time when using the module system:

    How can you extend the functionality of a module without having to "copy"
    the definitions of the underlying module "by hand"? In a case which I found
    particularly ugly (in the "res"-library), I had to "copy" nearly 100 lines
    as in:

      module Foo = struct
        module B = ...
        type t = B.t
        ...
        let iter = B.iter
        let iteri = B.iteri
        let map = B.map
        let mapi = B.mapi
        ...
      end

    Everytime the other module gets extended, I have to add code by hand here,
    too, to make it available. I do not see any simple workaround for this.
    Extending standard libraries with needed functionality would be much easier
    if there were a convenient way to get around the problem above.

    Regards,
    Markus Mottl

    -- 
    Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl
    



    This archive was generated by hypermail 2b29 : Fri Mar 10 2000 - 19:52:05 MET