Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] simple typing question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pixel <pixel@m...>
Subject: Re: [Caml-list] simple typing question
Xavier Leroy <> writes:

> No reasonably simple type system can distinguish both examples.  Many
> have been proposed -- this was a hot research topic in the 1980-1993
> time frame, and I even did my PhD on this very topic -- but none was
> found to be really usable in practice.  The value restriction on
> polymorphism (i.e. what Caml implements) is far from perfect, but is
> the "least bad" of the known solutions.

what about changing the semantic of partial application, restoring
eta-equivalence: a function is not evaluated unless every arguments
are given:

make_toggle()  <=>  fun x -> make_toggle () x

of course this makes functions like "make_toggle" quite useless:

# let make_toggle () =
    let r = ref [] in fun x -> let old = !r in r := x; old

would be semantically equivalent to

# let make_toggle () x =
    let r = ref [] in let old = !r in r := x; old

To get back the power of "make_toggle"-like functions, a special
function call could be added that would break eta-equivalence:
  call_now(make_toggle, ())
would have the semantic "make_toggle()" has in today's caml.

The rationale for this change would be that "make_toggle"-like
functions are seldom used, whereas "map"-like are used a lot.
Differentiating syntactically them would be nice.

But i don't think such a big change would do caml any good:
- are "make_toggle"-like functions really seldom used?
- performance drawbacks?

(i've been toying around the syntactical pb of partial application:
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: