Previous week   Up   Next week
Hello,

Here is the latest Caml Weekly News, week 22 to 29 january, 2002. 

Summary:
1) Ocaml and games
2) OCaml in the kernel (again)
3) Float and OCaml C interface
4) Mp3tag 1.1
5) an interesting programming problem

======================================================================
1) Ocaml and games
----------------------------------------------------------------------
Matthew D Moss wondered:

Just curious and wondering if anyone is doing (or has links to) games
coded with OCaml...  looking to get some opinions on overall structure
and/or feelings as to how well it is working for that.

(I am also reminded, having seen another email by Chris Hecker, that he
mentioned something along these lines at his talk at the last Game
Developers Conference.)

I am once again learning good 'ol ML language from college days, and
thought it might prove an interesting way to implement a game idea I
have (my idea requires little to no graphics, but IIRC there is a
ocaml-GL binding somehere).

(there were many answers to this message, you can find the whole thread
here: http://caml.inria.fr/archives/200201/msg00201.html )

======================================================================
2) OCaml in the kernel (again)
----------------------------------------------------------------------
Art Yerkes pondered:

I found the idea of ocaml code in the kernel intriguing enough to do
some digging. It turns out that ocamlopt can compile a viable kernel
if one hacks hard enough, and this allows the C parts of the kernel to
give ocaml code a shot at initialization, including allowing ocaml code
to register callbacks, etc that will be called when the kernel is
running.  The following page describes what's there, which while not
perfectly complete is enough to work with reasonably.  This may be a
nice opportunity to do a project like foxnet, but to get everything
except the ethernet physical-layer driver into a nicer language.  One
might consider that code thus written would be less exploitable by a
malicious hacker than equivalent C code.

Here is the page with instructions + files.
http://64.81.145.152/~arty/caml.html

======================================================================
3) Float and OCaml C interface
----------------------------------------------------------------------
Christophe Raffalli asked and Xavier Leroy answered:

> Is it possible to call from OCaml a C function of type double
> f(double,double,double) 
> without packing and unpacking the double when using the native code
> compiler ?

Yes.  Declare it as follows:

external f : float -> float -> float -> float = "f_wrapper" "f" "float"

"f_wrapper" should be the standard C wrapper function that takes three
values, unpacks the doubles, call f, packs the result.  This wrapper
will be called by the bytecode interpreter.

"f" is just the base C function taking unboxed doubles and returning a
double.  It will be called directly by the code generated by ocamlopt.

The "float" declaration at the end instructs ocamlopt to perform (and
optimize!) the unboxing of the arguments and the boxing of the result
itself, rather than relying on "f" to do it.

> In other word, is the unboxing optimization of floats available to
> external C function ?

Yes.  The standard library uses it for most of the floating-point
functions defined in Pervasives.

======================================================================
4) Mp3tag 1.1
----------------------------------------------------------------------
Maxence Guesdon announced:

Hello,

The release 1.1 of mp3tag is available at
http://www.maxence-g.net/Tools/mp3tag/mp3tag.html

It now includes support for id3 tags version 2.3, and
computation of information on mp3 file (length, average bit rate, ...).

All the read, write, and analysis functions were written by Xavier Leroy.

======================================================================
5) an interesting programming problem
----------------------------------------------------------------------
Doug Bagley said:

I thought some people might find this thread from comp.lang.lisp interesting:
(Subject = "Cute Little Problem")

http://groups.google.com/groups?hl=en&threadm=a2pmh7%24135ju5%241%40ID-125440.news.dfncis.de

The problem is sort of an interview question from a website, and the
task is to find related series of anagrams in a dictionary. People
were posting times of 10 seconds, 30 seconds, or even more (on fast
chips even), but using the native Ocaml compiler I can do it in (as of
now) in under 2 seconds on my old 400 Mhz Pentium II. A very informal
survey, of course, but it's the sort of thing that interests me.

One fellow asked for solutions (in any language) which he would
collect and summarize. So that was my motivation for giving it a
try. If anything comes of his study or if you are interested in the
source to my solution, let me know and I'll gladly give you an
update by email.

======================================================================

Alan Schmitt