Caml Weekly News Previous week Up Next week

Hello

Here is the latest Caml Weekly News, for the week of January 20 to 27, 2009.

  1. CamlPDF 0.4 Released
  2. Building with OCamlMkLib
  3. Conditional compilation wrt OCaml version?
  4. Tail calls in the JVM and the OCamlJava project

CamlPDF 0.4 Released

Archive: http://groups.google.com/group/fa.caml/browse_thread/thread/edec98d697b4dd2b#

John Whitington announced:
I've just updated CamlPDF to version 0.4:

http://www.coherentpdf.com/ocaml-libraries.html


The biggest change is that this release now compiles with Microsoft F Sharp as
well as with OCaml.

Some major non-compatible changes have been made to the low-level API, due to
our experience of building large software with the library. These should be
the last such changes, at least to the basic modules.

One of the changes is that many functions which used to take a Pdf.pdfdoc and
return another one now modify the document in-place. This is rather
un-idiomatic for a functional library, but threading all the documents through
complicated functions in code using CamlPDF became wearying.

There are several new modules:

PDFSpace (Parsing Colourspaces)
PDFText module extended for more encodings and better text extraction
Cff (Parse Type 1 fonts and convert to Type 3)
PDFMarks (Bookmark handling - unfinished)
PDFAnnot (PDF Annotations - unfinished)
PDFGraphics (Structured graphics - unfinished - included only because Cff uses
it

This release is about a third faster in general than the last one, due to
profiling under .NET. Many bug fixes are included, and extra facilities for
dealing with malformed PDF files.

CamlPDF is in commercial use in our Command Line PDF Toolkit and PDF Toolkit
for .NET.
			

Building with OCamlMkLib

Archive: http://groups.google.com/group/fa.caml/browse_thread/thread/66ad4b2458f93d08#

At the end of this thread, John Whitington said:
On 20 Jan 2009, at 17:03, John Whitington wrote:
> I'm building a Plain C interface to our PDF libraries, but am stuck. The idea
> is to build a library with Ocamlmklib containing the C wrapper around the
> ocaml code.

Thanks to those who helped me here - I finally settled on a modified version
of what's given in 18.8 in the manual.

Here are the new files:

http://www.coherentpdf.com/solution.tar.bz2

And here's what we ended up with...

ocamlc cpdflibc.mli
ocamlopt cpdflibc.ml
ocamlc cpdflibwrapper.c
ocamlopt -output-obj -o cpdflibc.o cpdflibc.cmx
cp /usr/local/lib/ocaml/libasmrun.a cpdflib.a
ar r cpdflib.a cpdflibc.o cpdflibwrapper.o

....producing the final cpdflib.a with which we can do...

cc -o test test.c cpdflib.a

....to use the library.
			

Conditional compilation wrt OCaml version?

Archive: http://groups.google.com/group/fa.caml/browse_thread/thread/c22ffa51bd7fbbc3#

David Teller-Rajchenbach asked:
  Working on Batteries, we're faced with a few places where we'd like to 
perform conditional compilation depending on the version of OCaml being 
used. We could probably do this with Camlp4, cpp, Autoconf hackery, etc. 
-- but first, we need to decide on which of these options we'll adopt. 

Any suggestion?
			
Sylvain Le Gall suggested:
There is optcomp: 
https://forge.ocamlcore.org/projects/optcomp/ 
http://darcs.ocamlcore.org/repos/optcomp/optcomp/README 

The example in README should talk to you directly.
			
Mikkel Fahnøe Jørgensen suggested:
If you are interested in using ocamlbuild you can have a look at
ocamlbuild-ctools:

http://dvide.com/labs/ocamlbuild-ctools/

I added extensions to ocamlbuild using a syntax like

normalfile.o
[mytag,myothertag,~notthistag]
conditionalfile.o
....

this is done in a .cprog file that lists all files to include, but
that same could be done with other similar files e.g. .mllib

Also, I added multi-variant builds so the same build can handle
multiple build targets based on tags - for example debug and release
builds. Multivariant builds work by adding tags in the filename:
myfile.variant_release,mingw.o


Most of this could be integrated into ocamlbuild, but ocamlbuild is
not very actively maintained as I understand.
			

Tail calls in the JVM and the OCamlJava project

Archive: http://groups.google.com/group/fa.caml/browse_thread/thread/80d88a5df82886dd#

Jon Harrop said:
For anyone who missed it, there has been a very interesting development in JVM 
land. Arnold Schwaighofer claims to have the first working implementation of 
tail calls on the recently open sourced Hotspot Java compiler:

 http://mail.openjdk.java.net/pipermail/mlvm-dev/2009-January/000331.html

Given the existence of the OCamlJava project, this should be of great interest 
to the OCaml community because it might pave the way to even better numerical 
performance and easier parallelism with simple interop to rich libraries and 
so forth.
			

Using folding to read the cwn in vim 6+

Here is a quick trick to help you read this CWN if you are viewing it using vim (version 6 or greater).

:set foldmethod=expr
:set foldexpr=getline(v:lnum)=~'^=\\{78}$'?'<1':1
zM

If you know of a better way, please let me know.


Old cwn

If you happen to miss a CWN, you can send me a message and I'll mail it to you, or go take a look at the archive or the RSS feed of the archives.

If you also wish to receive it every week by mail, you may subscribe online.


Alan Schmitt