Browse thread
[Caml-list] OCaml wishlist
[
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: | Richard Jones <rich@a...> |
| Subject: | [Caml-list] OCaml wishlist |
After writing a fair bit of OCaml in commercial situations (although
I'm by no means an expert, and really should learn camlp4), here's my
wishlist:
1. 'return' from a function. eg:
let foo x =
if x < 0 then return "OSL";
(* long & complex code *)
return "some other string"
I know I can do this using if ... else, but when you have multiple
levels of if ... else you end up being indented so far across the
screen as to make coding unpleasant. This is particularly a concern
with writing basically imperative UI code.
Is it possible to do something like this with camlp4? (as a stopgap -
I still think it should go into the language)
2. abstract data type syntactic sugar:
let hash = Hashtbl.create 16 in
hash#add "foo" 10; or: hash->add "foo" 10;
hash#add "bar" 20; or: hash->add "bar" 20;
The syntactic sugar is that if a module contains a type called
M.t (literally "type t"), and obj has type M.t, then:
obj#call [ or: obj->call ]
is exactly equivalent to:
M.call obj
I think this change would help a lot of Java programmers (<gr>) who
would otherwise tend to jump immediately on using objects, which are
an area where OCaml is weaker.
What do other people think?
Rich.
--
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you.
All new technology is irrelevant until it is taken up by the public.
-------------------
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