Ian T Zimmerman | 1 Jan 1999 09:21
Favicon

ANNOUNCE: mlexpect 0.9


mlexpect 0.9 has been uploaded to

ftp://ftp.prosa.it/pub/people/itz/mlexpect-0.9.0.tar.gz

All comments of any kind are heartily welcome.

I quote the README file:

This is mlexpect, a feeble attempt to to the same thing in ocaml as
Don Libes' expect program does in Tcl.

Install the GNU way: configure, make, make install.  This will add the
following to your system:

expect.cma	... a ocaml bytecode library 
expect_lib.mli	... a ocaml interface source file for the library
expect_lib.cmi  ... compiled interface file
mlexpect	... a ocaml toplevel with the expect library linked
in.

Also, for people who still miss C macro hackery :-) I added a camlp4
gizmo in expect_p4.cmo.  When you load it you can write things like

<:expect<
        spawn_id_0 * "exact string"     => handle_exact_string
        spawn_id_1 * /"pattern"/        => handle_pattern
        spawn_id_1 * Eof                => handle_eof
>>

(Continue reading)

Ian T Zimmerman | 4 Jan 1999 00:39
Favicon

Re: Dynamic link libraries

> Date: Tue, 22 Dec 1998 10:45:04 +0100
> From: Juan Jose Garcia Ripoll <jjgarcia <at> ind-cr.uclm.es>
> X-UIDL: e6222666435699efcb7296793c186224
> 
> Hi everyone,
>  let me introduce myself. I'm a newcomer to ML and to the world of
> functional programming in general. I'm currently giving OCaml and
> Moscow-ML a try. From OCaml I like the possibility of writing
> external C functions, but I dislike the limits that it imposes, that
> is:
>  * One has to generate a custom runtime
>  * One has to link those libraries against the runtime.
>  I believe this breaks modularity. Isn't it possible to support the
> following?
>  * Creation of *shared* bytecode/native-code Caml libraries.
>  * Dynamic loading of those libraries, much like Moscow-ML does: a
> simple 'load "filename.uo"'. (Moscow-ML is based on Caml-Light --
> thus I believe this must be possible, somehow)
>  * Linked executables (either native/bytecode ones) that make use of
> those libraries.
>  * Dynamick linking of native DLLs, that is, those which are
> generated by the C compiler, such as libX11.so, etc. This is just a
> matter of 30 lines code in Linux and other unices which support the
> `dlopen' function.
>  * Exposure of the symbols loaded from a DLL, so that they are
> recognized in "external" clauses.
>  This would lead to a better development evironment, and to some
> space saving due to not having to produce custom runtimes. I will
> appreciate any comment about why this hasn't been done already.

(Continue reading)

Xavier Leroy | 4 Jan 1999 17:27
Picon
Picon
Favicon

Re: Q: How i can use Mutex and thread ..

>   I have the following error :
>         Objective Caml version 2.01
> # let forks = Array.create 5 (Mutex.create());;
> Reference to undefined global `Mutex'

If you wish to use threads under the toplevel environment, you need to
build a custom toplevel first:

        ocamlmktop -custom -thread -o threadedocaml threads.cma -cclib -lthreads

(This is for bytecode threads; if you're using POSIX threads or
Windows threads, see the manual, chapter "The threads library", for
the correct libraries to use.)

Then, just run "threadedocaml" and voilà, you've got the thread
functions.

> P.S. Examples of Ocaml programs using thread are welcome

Enclosed below are two good examples: one shows a "producer" thread
and a "consumer" thread connected via a bounded circular buffer
(illustrates mutexes and conditions); the other is the well-known
channel-based sieve of Eratosthenes (illustrates events).

Hope this helps,

- Xavier Leroy

(******************** Classic producer-consumer **********************)

(Continue reading)

Christian Lindig | 5 Jan 1999 16:12
Picon
Picon

Simple XML Parser and Pretty Printer available


It is my pleasure to announce my simple Extensible Markup Language
(XML [1]) parser and pretty printer `Tony' written in Objective Caml. 
The parser is a spare time project and does not comply to the full XML
standard. 

    http://www.cs.tu-bs.de/softech/people/lindig/software/tony.html

The pretty printer is based on the pretty printing algebra proposed by
Philip Wadler [2] in his paper "A Prettier Printer".  His lazy
implementation was adopted for the strict evaluation of OCaml and may
be interesting in its own right.  The pretty printer module is
available in a separate library `mylib'. 

    http://www.cs.tu-bs.de/softech/people/lindig/software/mylib/index.html

Both distributions and their details can be found on the web pages
mentioned above.  The parser is most useful for programmers interested
in building XML applications in OCaml.  The usefullness of the stand
alone application `tony' is limited to make badly formatted XML code
readable. 

As always I would be glad to hear about success, failures,
improvements, bugs, and wishes.

-- Christian

References   
[1] http://www.w3.org/XML/
[2] http://cm.bell-labs.com/cm/cs/who/wadler/
(Continue reading)

Gerd Stolpmann | 5 Jan 1999 23:09
Picon
Picon

ANNOUNCEMENT: JavaCaml

Hi,

after two weeks of work I can announce JavaCaml, a reimplementation of the
Objective Caml bytecode interpreter in Java. As you expect after this
introduction, JavaCaml is slow, it is even very slow. But it is still
usable for many purposes that only want to provide a user interface for a
background service.

My motivation to program JavaCaml was to have an alternative for these bad
server-side applications, hacked in some of these fashionable languages
that can do anything even without concept. As being a client-side runtime
environment it is in JavaCaml no problem to preserve the current state,
and because of the high-level language facilities of Ocaml it is possible
to make user interfaces for structures that are more complicated than
simple lists.

I have made a homepage with much more information about JavaCaml, the
sources, and even two demos:

http://people.darmstadt.netsurf.de/Gerd.Stolpmann/javacaml

The current interpreter should be considered as experimental and does
currently not support all OCaml features. In detail, the object-oriented
concepts and many libraries are missing. But one important library already
works: Str, implementing regular expressions.

It would be nice to write what you think about the project. Especially, I
would welcome results of tests, suggestions for a good network API,
comments about the code quality, and, of course, anybody who helps me in
the further development.
(Continue reading)

Markus Mottl | 9 Jan 1999 21:24
Picon

Using modules and classes recursively

Hello - Bonjour,

Even though I have tried hard, I couldn't solve the following problem:

I want to have a class that is able to return a set of objects of
its type, but I have no idea, how I have to formulate this (if it is
possible).

E.g.:

---------------------------------------------------------------------------
class foo =
object
  method bar = FooSet.singleton (new foo)
end
---------------------------------------------------------------------------

An object of this class would return a set containing itself if its
member function "bar" is called.
Before the definition of this class, the module "FooSet" has to be
created. But it seems impossible to do so.

E.g.:

---------------------------------------------------------------------------
module FooSet =
  Set.Make (struct type t = <bar : FooSet.t> let compare = compare end)
---------------------------------------------------------------------------

This does not work, because the type constructor "FooSet.t" cannot be
(Continue reading)

Patrick Loiseleur | 8 Jan 1999 10:35
Picon

OCaml wins a comparative study


According to D. McClain, OCaml is currently the best programming
language for scientific processing. At the URL

http://www.azstarnet.com/~dmcclain/LanguageStudy.html

one can found a detailed comparative study of C++, IDL, Fortran, SML,
Ocaml, Dylan, Erlang, Clean, Haskell, Lisp, Mathematica. O'Caml is
praised for the easyness of code writing and code maintenance, hi-quality
documentation but also for the speed of the compiler and the quality
of code generated :

<< And most importantly, the CAML version works, and it works properly?
every time. I am assured, having monitored its runtime behavior that
there are no memory leaks. Furthermore, the quality of code generated
by the CAML compiler has been analyzed by the Intel VTune system and
it show no pipeline stalls, maximum parallelism between integer and
floating point units, and machine assembly code that is as good or
better than can be achieved by hand coding.>>

[Version francaise]
Ocaml est le vainqueur d'une confrontation entre plusieurs langages de 
pogrammation (C++, IDL, Fortran, SML, Ocaml, Dylan, Erlang, Clean,
Haskell, Lisp, Mathematica) utilsés pour des calculs
scientifiques. Les vertus reconnues à OCaml sont la clarté du code,
la facilité de la maintenance et la qualité de la documentation, mais
aussi la vitesse et la qualité du code généré.
On peut consuler cet article à l'adresse : 

http://www.azstarnet.com/~dmcclain/LanguageStudy.html
(Continue reading)

Markus Mottl | 7 Jan 1999 13:34
Picon

side effects on object destruction

English version:

Hello,

I would like to know whether it is already somehow possible to yield
side effects when an object ceases to exist. There is nothing about
destructors in the OCAML-documentation.  This would allow e.g. closing
of open channels or other measures for "cleaning up".

Regards,
Markus Mottl

Version française:

Bonjour,

Je voudrais savoir s'il est déjà possible d'obtenir des "side effects"
si un objet fini d'exister. Je n'ai rien trouver sur des "destructors"
dans la documentation de OCAML. Ils le feraient possible de (par exemple)
fermer des canaux ouverts.

Cordialement,
Markus Mottl

--

-- 
Markus Mottl, mottl <at> miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl

Juan Jose Garcia Ripoll | 10 Jan 1999 11:49
Picon

Map is not tail recursive

Hi,

I've had a look at the List package and it seems that it is not properly
tail recursive. Even more, for medium to large lists it exhausts the
stack. I would suggest either recoding it as

let map f a =
   let domap f done todo =
      match todo with
         [] -> List.reverse done
       | (x::xs) -> domap (f x)::done xs
   in domap f [] a

Another possibility would be to introduce destructive operations such as
Scheme's setcdr! and setcar!. This would eliminate the need of using
List.reverse, at the cost of introducing some imperative style.

Please excuse any mistake -- I'm quite new to this language.

Regards

	Juanjo

David McClain | 11 Jan 1999 19:51
Picon
Favicon

Re: Map is not tail recursive

Juan got me thinking about this problem... So here is a solution:

external rplacd : 'a list -> 'a list -> unit = "rplacd"

let list_map fn lst =
  (* A properly tail recursive definition of Map *)
  match lst with
      [] -> []  (* OCAML represents [] specially - can't rplacd *)
    | h :: t ->
         let rslt = [fn h] in
         let rec iter lst tail =
            match lst with
               [] -> rslt
             | h :: t ->
                  let elt = [fn h] in
                  rplacd tail elt;
                  iter t elt
         in
           iter t rslt

-- and the external C code is

value rplacd(value cell, value item)
{
  Store_field(cell,1,item);
  return Val_unit;
}

-----Original Message-----
From: Juan Jose Garcia Ripoll <jjgarcia <at> ind-cr.uclm.es>
(Continue reading)


Gmane