9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] ocaml for plan9
@ 2003-05-14 20:28 andrey mirtchovski
  2003-05-14 21:27 ` Dan Cross
  0 siblings, 1 reply; 2+ messages in thread
From: andrey mirtchovski @ 2003-05-14 20:28 UTC (permalink / raw)
  To: 9fans

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 <n/y> ? 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 = <fun>
# let rec fact (x) = if x <= 1 then 1 else x * fact (x-1);;
val fact : int -> int = <fun>
# 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.





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9fans] ocaml for plan9
  2003-05-14 20:28 [9fans] ocaml for plan9 andrey mirtchovski
@ 2003-05-14 21:27 ` Dan Cross
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Cross @ 2003-05-14 21:27 UTC (permalink / raw)
  To: 9fans

Neat.  Does this compile to a native object code, or some sort of P-code
represtation?

	- Dan C.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-05-14 21:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-14 20:28 [9fans] ocaml for plan9 andrey mirtchovski
2003-05-14 21:27 ` Dan Cross

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