Loading ...
Sorry, an error occurred while loading the content.
 

Re: "ocaml_beginners"::[] Multiple directories.

Expand Messages
  • Thaddeus L. Olczyk
    On Thu, 27 Nov 2003 11:16:24 +0000, Richard Jones ... Makefiles aren t the only problem. One example ( that I remember was a problem in the
    Message 1 of 12 , Dec 1, 2003
      On Thu, 27 Nov 2003 11:16:24 +0000, Richard Jones <rich@...>
      wrote:

      >It sounds like an ordinary Makefile can do what you want.
      Makefiles aren't the only problem.

      One example ( that I remember was a problem in the past ).
      If I build two different libraries, a.cma and b.cma in different
      directories how can I load them into the top in a way that is
      directory independent?

      ( BTW your Makefile does explicitly depend on where some
      of the libs are installed. )

      A bigger example that I am now encoutnering is this.
      I wrap some OS calls in C functions and call the C functions
      from OCaml. I build cma and I build a toplevel. The C code is
      kept in an object file ( not a dll/so ), and linked in. The problem
      is that I can only open the toplevel or do a #load "dir/xxx.cma";;
      if my pwd is the dir of xxx.cma.

      If I try to start the toplevel from some other directory, then I
      cannot open the module xxx. It tells me that xxx is an unbound module.
      ( But starting in the directory it is OK. )

      If I try to start the standard toplevel ( ocaml or ocaml.exe ), and do
      #load "dir/xxx.cma";; I get an undefined symbol error. Of course it
      loads OK if the pwd is the dir of xxx.cma.







      Thaddeus L. Olczyk
      -----------------------
      Think twice, code once.
    • Thaddeus L. Olczyk
      On Fri, 28 Nov 2003 14:28:11 +0100, Hendrik Tews ... Uhm. I m not quite sure what the language barrier here is, but clearly you misunderstand. When I say
      Message 2 of 12 , Dec 1, 2003
        On Fri, 28 Nov 2003 14:28:11 +0100, Hendrik Tews
        <tews@...-dresden.de> wrote:

        >
        > Took a look, but something is missing.
        > It would be nice write a function to generate
        > an "unwind-protected" function.
        >
        >You don't need to generate. You simply use higher-order functions
        >like make_protected.
        >
        Uhm. I'm not quite sure what the language barrier here is, but clearly
        you misunderstand.

        When I say "unwind-protected" function I mean a function which is
        similar to the original but with an unwind-protect type wrapper.

        When I say generate, I don't mean anything formal. Simply that
        a function takes a function and returns a modified function.
        A higher-order function no? So what I am saying would include
        make_protected.

        >If you really insist to generate the protected function you can
        >always use your favourite preprocessor, like m4 or cpp to
        >preprocess your ocaml sources.
        Yuch. Klude.
        >You can also use camlp4, the ocaml
        >preprocessor/pretty-printer.
        >
        Less of a kludge, but yet still a kludge.

        > The problem being that a resource can be acquired using
        > no parameters,
        >
        >Use a dummy () argument.
        >
        My mistake.
        I envisioned a function f with signature ()->x/
        I thought the make_protected could not handle
        such a function. I see now that it can.


        > one parameter, two parameters etc...
        >
        >pack the arguments in a tuple
        >
        > The other problem being that the function only takes one ( or two if
        > you count handle ) parameter. It's hard to see how to generalize.
        >
        >Same thing. You pass tuples of ressources around.
        >

        Uhm. It's the same point.

        I have a problem with changing multiple arguments to tuples.

        First functions don't usually come that way, so I have to modify
        the each function by hand. Second the function that is produced
        likely takes a tuple as an argument. Since that is not the way the
        original function works, it will cause confusion. So I have to curry
        the function, probably by hand each time. Third I have to
        remember these two steps each time I do this on a function.

        If there was some curry/uncurry function, then it wouldn't be
        a problem, but AFAIK no such functions exist.
        Thaddeus L. Olczyk
        -----------------------
        Think twice, code once.
      • Stalkern 2
        ... Don t the include flags do that? if you compile with -I subdir things should be straightforward AFAIK. Ernesto
        Message 3 of 12 , Dec 2, 2003
          Il Tuesday 02 December 2003 07:08, Thaddeus L. Olczyk ha scritto:
          > One example ( that I remember was a problem in the past ).<BR>
          > If I build two different libraries, a.cma and b.cma in different<BR>
          > directories how can I load them into the top in a way that is<BR>
          > directory independent?

          Don't the include flags do that? if you compile with
          -I subdir
          things should be straightforward AFAIK.

          Ernesto
        • Hendrik Tews
          Thaddeus L. Olczyk writes: I have a problem with changing multiple arguments to tuples. You are right. The necessary currying/uncurrying can get cumbersome. If
          Message 4 of 12 , Dec 5, 2003
            Thaddeus L. Olczyk writes:

            I have a problem with changing multiple arguments to tuples.

            You are right. The necessary currying/uncurrying can get
            cumbersome.

            If there was some curry/uncurry function, then it wouldn't be
            a problem, but AFAIK no such functions exist.

            Well, you can define

            let curry f = fun x -> fun y -> f (x,y)

            but this does not really solve your problem.

            You are right, you cannot define curry such that it curries n
            arguments, where n is the first argument passed to curry. I am
            sure you can do this in camlp4.

            Bye,

            Hendrik
          • Martin Jambon
            ... Such a function cannot exist: Just compare curry f a b c vs. (curry f a b) c
            Message 5 of 12 , Dec 8, 2003
              Thaddeus L. Olczyk writes:

              > If there was some curry/uncurry function, then it wouldn't be
              > a problem, but AFAIK no such functions exist.

              Such a function cannot exist:

              Just compare
              curry f a b c
              vs.
              (curry f a b) c
            Your message has been successfully submitted and would be delivered to recipients shortly.