caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dmitry Lomov <dsl@intellij.com>
To: A Joseph Koshy <koshy@india.hp.com>,
	Xavier Leroy <xavier.leroy@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] The need for opcode GRAB?
Date: Fri, 15 Nov 2002 16:00:31 +0300	[thread overview]
Message-ID: <200211151600.31088.dsl@intellij.com> (raw)
In-Reply-To: <200211150915.OAA10510@postbox.india.hp.com>

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:

implementation A.ml:
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?)

Cheers,
Dmitry


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2002-11-15 13:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-15  9:15 A Joseph Koshy
2002-11-15 13:00 ` Dmitry Lomov [this message]
2002-11-15 19:24   ` Blair Zajac
2002-11-16  0:18     ` Alan Schmitt
2002-11-18  8:29       ` Dmitry Lomov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200211151600.31088.dsl@intellij.com \
    --to=dsl@intellij.com \
    --cc=caml-list@inria.fr \
    --cc=koshy@india.hp.com \
    --cc=xavier.leroy@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).