Previous week Up Next week

Hello

Here is the latest Caml Weekly News, for the week of 09 to 16 November, 2004.

  1. Ocamllex Tutorial
  2. ocamlyacc tutorial (v. 0.3)
  3. ansicolor-0.5
  4. Native executable symtable
  5. alpha testing of ocamlfuse
  6. calendar library: new release (1.09.0)

Ocamllex Tutorial

Archive: http://caml.inria.fr/archives/200411/msg00080.html

SooHyoung Oh announced:
I'm pleased to announce "ocamllex tutorial".

----------------------------

Abstract

This is a tutorial on how to use ocamllex which is distributed with Ocaml
language.

This document borrowed lots of part from flex manual.

Please mail all comments and suggestions to <shoh at compiler dot kaist dot
ac dot kr>

This tutorial is work-in-progress. The latest version can be found at
http://pllab.kaist.ac.kr/~shoh/ocaml/ocamllex-ocamlyacc/ocamllex-tutorial/index.html .

The companion tutorial for ocamlyacc will be available at
http://pllab.kaist.ac.kr/~shoh/ocaml/ocamllex-ocamlyacc/ocamlyacc-tutorial/index.html .

You can find the source of this document in ocamllex-tutorial-src.tar.gz.
For printing, pdf (A4 size) is presented, and there is html (tar.gz).

You can download the source of examples used in this document from
ocamllex-examples.tar.gz.

Last updated: 2004-11-10
    

ocamlyacc tutorial (v. 0.3)

Archive: http://caml.inria.fr/archives/200411/msg00081.html

SooHyoung Oh announced:
This is newer version of "ocamlyacc tutorial".

 -----------------------------
Abstract

This is a tutorial on how to use ocamlyacc which is distributed with Ocaml
language.

Lots of part of this document are borrowed from the bison manual.

All license term in this document is NOT related with ocamlyacc; it is ONLY
for this document.

Please mail all comments and suggestions to <shoh at compiler dot kaist dot
ac dot kr>

This tutorial is work-in-progress. The latest version can be found at
http://pllab.kaist.ac.kr/~shoh/ocaml/ocamllex-ocamlyacc/ocamlyacc-tutorial/index.html .

The companion tutorial for ocamllex is available at
http://pllab.kaist.ac.kr/~shoh/ocaml/ocamllex-ocamlyacc/ocamllex-tutorial/index.html .

You can find the source of this document in ocamlyacc-tutorial-src.tar.gz.
For who wants the other form, pdf (A4 size) for printing and html (tar.gz)
are presented.

The source of the examples used in this document can be found
ocamlyacc-examples.tar.gz.

Last updated: 2004-11-10
    

ansicolor-0.5

Archive: http://caml.inria.fr/archives/200411/msg00085.html

Owen Gunden announced:
O'Caml ANSIColor is a library for creating colorful text and other
effects in ANSI-compatible terminals.  The code is staggeringly simple,
and the interface and implementation are both very roughly based on
Term::ANSIColor (a CPAN module).

Homepage: http://projects.phauna.org/ansicolor/
API: http://projects.phauna.org/ansicolor/doc/
Tarball: http://projects.phauna.org/ansicolor/release/ansicolor-0.5.tar.gz
GODI package: godi-ansicolor*

*: currently there is only a godi package for the 3.08 GODI
distribution.  If there is demand and someone is willing to test with
3.07 I will gladly put the package into the 3.07 distribution as well.

That is all.
    

Native executable symtable

Archive: http://caml.inria.fr/archives/200411/msg00100.html

Alex Baretta asked:
We are writing a library implementing binary client-server protocol 
based on the Marshal module. In order to guarantee some degree of 
type-safety, during the handshaking phase of the communication we need 
the client to send the server the MD5 checksums of all relevant modules. 
The server process must verify that it has all the mentioned modules and 
that the checksums are consistent with its own.

We are currently generating MD5 checksums from our source files with the 
md5sum command. These checksums are then assembled into a new source 
file which is compiled and linked into the both executables. This 
process works coherently for byte and native code, but it has at least 
one important drawback: all relevant modules must be available as source 
files for the md5 source file generation to work. Besides, this makes 
the compilation process exceedingly complex.

We have found that the md5sum can be fetced directly from the executable 
file associated to the process. This technique is documented nowhere, as 
far as I can see, but the source code of Symtable.init_toplevel is very 
informative as to how to do this for bytecode executables. What I would 
like to know is how to implement this technique for native code 
executables. Essentially, how am I supposed to parse the binary 
executable to extract the symtable information. Also, how am I supposed 
to figure out at runtime whether I must use the bytecode method or the 
native code method? Equivalently, how do I know at runtime if the 
process is running a bytecode executable or a native one?

Thank you very much.
    
Xavier Leroy answered:
> We have found that the md5sum can be fetced directly from the executable 
> file associated to the process. This technique is documented nowhere, as 
> far as I can see, but the source code of Symtable.init_toplevel is very 
> informative as to how to do this for bytecode executables. What I would 
> like to know is how to implement this technique for native code 
> executables. Essentially, how am I supposed to parse the binary 
> executable to extract the symtable information.

You cannot, because the checksums you mention (the digests of the
interfaces of the modules) are not included in ocamlopt-generated
executables.  They are included only in ocamlc-generated executables (in
the CRCS section) for use with Dynlink and the toplevel.

At any rate, I think you're on the wrong tracks: the checksums you'll
find in the CRCS section of bytecode executable are those of module
interfaces, not of module implementations.  To establish type
agreement between two processes communicating via
output_value/input_value, you really want the latter, not the former.
(Think of an abstract type implemented differently in the two
processes.  For more details, see e.g. the ICFP'03 paper by Leifer,
Peskine, Sewell and Wansbrough.)

So, you're looking for convenient ways to collect checksums for module
implementations.  An insight that might simplify your build process is
that while these checksums must be computed at compile-time (e.g. by
running md5sum on the source .ml files), they can be collected
together at run-time.  For instance, you could preprocess the .ml
sources of interest so as to insert at the beginning

        let _ = Registry.record_module "Modulename" "checksum"

where "Modulename" is the module name and "checksum" the outcome of
md5sum on the source file.  The Registry.record_module function just
accumulates its arguments in a hashtable or association list, which
can then be consulted during the agreement phase of your protocol.

There are probably many other ways to do it.  But I think your initial
idea (compute checksums of source files at compile-time) is the
correct one, it's just a question of implementing it in a way that
doesn't complicate your build process too much.
    

alpha testing of ocamlfuse

Archive: http://caml.inria.fr/archives/200411/msg00125.html

Vincenzo Ciancia announced:
Hi all, I am trying to write a complete, up-to-date, efficient and 
correctly multithreaded binding to the fuse api for ocaml. Fuse is a 
linux kernel module allowing filesystems to be implemented in user 
space, see

http://www.sourceforge.net/projects/fuse

By now, OCamlFuse is complete and up-to-date, but multithreading has 
troubles. Anyway, I declare the single-threaded version to be in 
alpha-testing (i.e. internal, developers testing). Since I consider the 
developers of any free-software projects to be everybody willing to 
join, I announce it here, in the hope that someone will want to have a 
look at my efforts and to test it, write some example filesystem in 
ocaml, comment on the interface and possible improvements in 
implementation, or even better to help with multithreading, which 
"should" work but crashes under heavy load for mysterious reasons. 

Help or advices for packaging are also wanted, since I don't know too 
much about GODI or ocamlfindlib and have not so much free time to work 
on this project. I will answer to any question on the ocamlfuse-devel 
mailing list, please read the README to know fundamental issues.

The source lives in the cvs; you can find everything needed, including 
the mailing list, on the sourceforge project page:

http://www.sourceforge.net/projects/ocamlfuse

I did everything in a hurry, and on a by-need basis, I am not an expert 
user of the ocaml C interface, so if you have suggestions, don't 
hesitate to tell me :)
    
Matt Gushee asked and Vincenzo Ciancia answered:
> I'm interested in this. First of all, what was wrong with the
> existing mlfuse library? (I'm not saying there's nothing wrong with
> it, I just don't know--hadn't tried it yet).

It's not up-to-date (fuse is going towards its 2.1 release, while the 
existing mlfuse is for fuse 0.9), and it was not designed with 
multithreading in mind. If the latter was not true, I would not have 
rewritten it, however by now I must record a failure, since I did this 
all to get multithreading working and had no success :/ I am going to 
try to spot the problem this weekend - it's related to a previous 
recent post of mine on this list.

Apart from this, a question to the list: to implement the read and write 
operations I am constrained to string copying. Is there a way to share 
a string with C in ocaml or should I roll my own "cstring" type and use 
that, copying from/to strings using memcpy when necessary?
    

calendar library: new release (1.09.0)

Archive: http://caml.inria.fr/archives/200411/msg00128.html

Julien Signoles announced:
I'm please to announce that a new (major) release (version 1.09.0) of the
calendar library is available at:

	http://www.lri.fr/~signoles/prog.en.html

calendar is an ocaml library managing dates and times. The latest changes
follow. In particular, this release adds features of Richard Jones'
GregorianDate.

CHANGES:
* add Date.to_business and Date.from_business (Richard Jone's suggestion)
* add the optional parameter ?month to Date.days_in_year
        (Richard Jones' suggestion)
* add Date.nth_weekday_of_month (Richard Jones' suggestion)
* Date: add some Christian dates (Richard Jones' suggestion)
* add Date.Period.ymd and Calendar.Period.ymds
* Printer: add the format string %i corresponding to the ISO-8601 notation
* Printer: ISO-8601 notation is now the default format
* add [equal] in all the modules
* Calendar.Period: bug fixed with negative period
* bug fixed in Calendar.to/from_unixfloat and Date.to/from_unixfloat
* bug fixed in weeks_in_year
    
Owen Gunden added:
And the godi package (godi-calendar) has been updated to version 1.09.0.
Give it a whirl!
    

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}$'?'&lt;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