Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] productivity improvement
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-07-10 (15:50)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] productivity improvement
Michael Vanier wrote:

>Imperative code in ocaml is not going to be massively different than
>imperative code in any other (garbage-collected) language.  
I don't agree.

All imperative languages -- including ocaml -- contain functional parts,
usually known as 'expressions'. The ability to write clear and simple
imperative code is greatly enhanced by a powerful functional system
precisely because it allows the imperative part of the language to
be used just for imperative things. In a language like C the
functional system is so weak, that one must use the imperative
features just to implement purely functional constructions.

For example, you cannot initialise a structure in C except
with an imperative statement:

    X x = {1,2,3,4};

For example, you cannot encode a switch (other than
over a bool) in an expression: you have a to use a statement,
although you can wrap it in a function and call that ..
although of course you lose your environment and so you need
to pass them ... argggrgrgrg. Perhaps you can do better with:

    int x = expr;
    result =
        x==1 ? blah1() :
        x==2 ? blah2():
        x==3 ? blah3():

As someone said recently "ocaml forever" :-))

John Max Skaller,
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: