OT: Ocaml?
Donn Cave
donn at drizzle.com
Sat Aug 23 22:50:09 EDT 2003
Quoth Paul Rubin <http://phr.cx@NOSPAM.invalid>:
| Arne Koewing <ark at gmx.net> writes:
|>> Anyone here use OCAML? How do you like it? Is it a language a
|>> Pythonista can learn to love? From what little I've seen, it looks
|>> interesting, but I haven't actually tried installing or using it yet.
|> Yes and I think it's a great language, but it's a little bit harder
|> to start learning it. (you must learn how to read the types).
|> But you get a very 'save' language with a very efficient compiler.
|
| Do you find that the strict type system gets in your way like it does
| in Java?
I have used ocaml only casually, and Java never, but one thing
that has worked for me is sort of a functional counterpart of
OOP, ``partial application.''
let multiply a b = a * b
let double = multiply 2
So supposing I want something like Python's file object.
let read_file fp sz = ...
let write_file fp data sz = ...
let make_file_file fp =
{
read = read_file fp;
write = write_file fp
}
let f = make_file_file (open filename) in
let data = f.read 512
...
let read_buffer buffer sz = ...
The point being that the type system, though probably stricter
than Java's, does allow ways to conveniently implement the same
interface for radically different types, in this case with a
feature that's just a basic natural part of any functional
programming language. Maybe Java could do the same?
Then there is a lot of stuff in Objective CAML's module system
that directly addresses type issues, and it also has a fairly
complicated OOP system.
Donn Cave, donn at drizzle.com
More information about the Python-list
mailing list