From mboxrd@z Thu Jan 1 00:00:00 1970 From: andrey mirtchovski To: 9fans@cse.psu.edu Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: [9fans] ocaml for plan9 Date: Wed, 14 May 2003 14:28:04 -0600 Topicbox-Message-UUID: ab33b614-eacb-11e9-9e20-41e7f4b1d025 Hi, I've completed an APE port of ocaml for Plan9. You can download the source here: http://pages.cpsc.ucalgary.ca/~mirtchov/p9/ocaml/ What is this? This is a port of the Ocaml (Caml is the language, Ocaml is "Objective Caml") functional (and more) programming language to the Plan 9 from Bell Labs Operating System. To get more information about Ocaml go to: http://caml.inria.fr/ To get more information about Plan 9 go to: http://plan9.bell-labs.com/plan9dist A good bunch of examples can be found at: http://caml.inria.fr/Examples/oc.tar.gz Warning -- not all examples would compile! Here is a taste of some of the examples and the ocaml interpreter: cpu% ape/psh $ make ocamlc -g -c hello.ml ocamlc hello.cmo -o hello ocamlc -g -c greeting.ml ocamlc greeting.cmo -o greeting ocamlc -g -c argcargv.ml ocamlc argcargv.cmo -o argcargv [snip] $ ./hello Hello world! $ cat wc_unix.ml | ./wc 2761 characters, 367 words, 86 lines $ queens Chess boards's size ? 5 The 5 queens problem has 10 solutions. Do you want to see the solutions ? y Solution number 1 - - - Q - - Q - - - - - - - Q - - Q - - Q - - - - Solution number 2 - - Q - - - - - - Q - Q - - - - - - Q - Q - - - - Solution number 3 - - - - Q - - Q - - Q - - - - - - - Q - - Q - - - Solution number 4 - - - Q - Q - - - - - - Q - - - - - - Q - Q - - - Solution number 5 - - - - Q - Q - - - - - - Q - Q - - - - - - Q - - Solution number 6 Q - - - - - - - Q - - Q - - - - - - - Q - - Q - - Solution number 7 - Q - - - - - - - Q - - Q - - Q - - - - - - - Q - Solution number 8 Q - - - - - - Q - - - - - - Q - Q - - - - - - Q - Solution number 9 - - Q - - Q - - - - - - - Q - - Q - - - - - - - Q Solution number 10 - Q - - - - - - Q - Q - - - - - - Q - - - - - - Q $ Examples of the ocaml interpreter: cpu% ocaml Objective Caml version 3.06 # let square (x) = x * x;; val square : int -> int = # let rec fact (x) = if x <= 1 then 1 else x * fact (x-1);; val fact : int -> int = # fact(5) ;; - : int = 120 # square(5);; - : int = 25 # square(fact(2));; - : int = 4 # What's there: This port uses the APE environment, i.e. it is not native. All of the unix functionality that ocaml needs and APE supports is there. The interpreter seems to run but is not thoroughly tested (I am not very fluent in Caml). What's missing: Graphics libraries aren't there (they need to be rewritten using draw(). I don't need ocaml-x11 that bad to do it myself) Thread libraries are not there -- both posix and non-posix threads are missing, same as with the above lib. Tk libraries are not compiled too, same reason. The code is there (config/Makefile turns on the compilation) so if you're willing... Gotchas: Probably many. You'll have to play with it to find out. I am barely an ocaml user myself, so you shouldn't expect to find them miraculously fixed in the next release (if there's any :) This port was hard. APE's make doesn't deal well with things like $(BLAH:.a=.b), which required an edit of almost every Makefile. Long filenames, messy compilations and even bugs in their #ifdef-sprinkled code took about three work days to catch. Not nice at all. Compile instructions: gunzip < ocaml-plan9-3.06.tgz | tar xv cd ocaml-3.06/ lnfs ocamldoc # if you don't use fossil lnfs /sys/man/man1 # if you don't use fossil ape/psh make world make install BUGS: The code is non-portable. the endianness is defined in config/m.h; unless the plan9 compilers can handle that fact you won't be able to run ocaml on a different architecture. (If I'm wrong please tell me!) Having to run "lnfs /sys/man/man1"!!! the installation process puts way too many binaries in /386/bin. There should be an easier way to switch between /$objtype/[bin|lib] and $home/[bin|lib] You will need to run: lnfs ocamldoc lnfs /sys/man/man1 due to the fact that three of the ocaml web pages have long filenames. The best way to deal with this is to have a Venti/Fossil system underneath. Most bugs would require that you go there and solve them yourselves. This port does not attempt to bring a full environment for ocaml lovers, rather it just solves a request somebody posted on the TODO page of the Plan 9 Wiki. TODO: plan9-native ui libs; Tk libs; threads assembly optimizations (well, maybe not) completely native port? wouldn't be easy.