Browse thread
[Caml-list] productivity improvement
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners