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

2753Re: "ocaml_beginners"::[] Re: 'ocaml_beginners'::[] Execution semantics

Expand Messages
  • Remi Vanicat
    Nov 5, 2004
      On Fri, 5 Nov 2004 13:10:40 +0000, Richard Jones <rich@...> wrote:
      >
      >
      >
      > On Fri, Nov 05, 2004 at 11:49:41AM +0900, Nicolas Cannasse wrote:
      > > > f will be '_a -> '_a ref
      > > if it's type was 'a -> 'a , that means we can put any unifiable function
      > > into the reference f and call it later with another type :
      > >
      > > f := (fun x -> x + 1) // would unify since int -> int is unifiable with
      > > 'a -> 'a
      > > !f "hello" // would works since !f would still be 'a -> 'a, causing a typing
      > > error since we're actually executing above function
      > >
      > > So it's needed to introduce monomorphic variables, they are really
      > > "temporary" polymorphic variables until they're unified.
      >
      > And I think it's also true that '_a will only ever appear in the
      > toplevel, never when writing proper applications.
      >

      Not exatly, the fact is that if there is an '_a type in a proper
      application, this is an error, and the compiler will refuse to compile
      it.
    • Show all 26 messages in this topic