Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Announce: Nativize 0.1
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Issac Trotts <ijtrotts@u...>
Subject: [Caml-list] Announce: Nativize 0.1
Nativize : Compile and run native functions from the toplevel.

http://redwood.ucdavis.edu/~issac/software/nativize-0.1.tar.gz

Introduction
============
  It is useful to be able to easily run native code from the toplevel.
  Nativize makes this possible for functions whose arguments and return
  values can be serialized using the functions in OCaml's Marshal
  module.

Example: running Ackermann's function in the toplevel
=====================================================

# #require "nativize";;
Loading /usr/lib/ocaml/3.07/nativize/nativize.cma
# Nativize.nativize "Ack1" "
  let rec ack m n =
      if m = 0 then n + 1
      else if n = 0 then ack (m - 1) 1
      else ack (m - 1) (ack m (n - 1));;
  " [];;
Please type #load "Ack1.cmo";;
- : unit = ()
# #load "Ack1.cmo";;
# assert(Ack1.ack 5 0 = 65533);; (* Wait about 10 seconds. *)
- : unit = ()
# let rec ack m n =
      if m = 0 then n + 1
      else if n = 0 then ack (m - 1) 1
      else ack (m - 1) (ack m (n - 1));;
# ack 5 0;;  (* Wait a good while longer. *)

-- 
Issac Trotts
http://redwood.ucdavis.edu/~issac

-------------------
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