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] The need for opcode GRAB?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-11-15 (13:03)
From: Dmitry Lomov <dsl@i...>
Subject: Re: [Caml-list] The need for opcode GRAB?
On Friday 15 November 2002 12:15, A Joseph Koshy wrote:
> Perhaps a basic question about the O'Caml bytecode interpreter:
> Why do we need to check at runtime if a function is being
> partially applied?  Isn't this information available to the
> compiler?

No it is not:

let f x y = x + y
let g x = if x = 1 then fun y -> y else fun y -> y - 1

interface A.mli:
val f : int -> int -> int
val g : int -> int -> int

usage (somewhere outside A):
let k = (A.f 1) (* this application is partial *)
let r = (A.g 1) (* this application is not partial *)

Compiler cannot distinguish between those two cases
(knowing only A interface).

BTW a GRAB/RESTART trick is very cool IMHO.
My students always "Wow!" at it. Any references as to
where it comes from (or was it a Xavier's own clever idea?)


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: