Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
Cc: caml-list@inria.fr
Subject: Re: Self-detection of native code execution (Was Re: [Caml-list] Accuracy of Gc.stat ())
Date: Sat, 22 Nov 2003 14:28:52 +0000	[thread overview]
Message-ID: <20031122142852.GA12413@redhat.com> (raw)
In-Reply-To: <0C871798-1CF7-11D8-8FEF-000393DBC266@epfl.ch>

On Sat, Nov 22, 2003 at 03:20:40PM +0100, Daniel B?nzli wrote:
> 
> Le 22 nov. 03, ? 12:49, Richard Jones a ?crit :
> 
> >>Neat trick. This _ought_ to work, but it doesn't for some reason:
> >>
> >>	let arg = (true, false)
> >>	external is_bytecode : bool * bool -> bool = "%field0" "%field1"
> >>
> >>	let () =
> >>	  if is_bytecode arg then
> >>	    print_endline "Bytecode!"
> >>	  else
> >>	    print_endline "Native!"
> >>
> >>Perhaps someone can explain why ...
> 
> Nice try, too bad it doesn't work. I would even prefer that one :
> 
> let arg = true
> external is_bytecode : bool ->  bool = "%identity" "%boolnot"
> 
> let () =
>   if is_bytecode arg then
>     print_endline "Bytecode!"
>   else
>     print_endline "Native!"
> 
> 
> >OK, closer inspection of the manual[*] reveals why this doesn't work.
> >Surely OCaml should flag the above code as a bug, because there are
> >fewer than the magical 6 arguments?
> 
> The strange thing is that the function given by Kim also have fewer 
> than 6 arguments.

True, but his code doesn't actually use the values of the arguments
passed to the C functions.

What is needed is a primitive function which ignores its arguments and
returns a known value. But I don't think there is such a primitive in
the current compiler. (Not as far as I can see by looking at
bytecomp/translcore.ml anyway).

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
"One serious obstacle to the adoption of good programming languages is
the notion that everything has to be sacrificed for speed. In computer
languages as in life, speed kills." -- Mike Vanier

-------------------
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:[~2003-11-22 14:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-19 17:52 [Caml-list] Accuracy of Gc.stat () Daniel Bünzli
2003-11-21 16:46 ` Damien Doligez
2003-11-22  0:20 ` Kim Nguyen
2003-11-22 11:43   ` Richard Jones
2003-11-22 11:49     ` Richard Jones
2003-11-22 14:20       ` Self-detection of native code execution (Was Re: [Caml-list] Accuracy of Gc.stat ()) Daniel Bünzli
2003-11-22 14:28         ` Richard Jones [this message]
2003-11-22 14:28       ` [Caml-list] Accuracy of Gc.stat () Kim Nguyen
2003-11-22 14:31         ` Richard Jones

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=20031122142852.GA12413@redhat.com \
    --to=rich@annexia.org \
    --cc=caml-list@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