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] OCaml wishlist
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-10-21 (14:29)
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

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: 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?


Richard Jones.
Merjis Ltd. - all your business data are belong to you.
 All new technology is irrelevant until it is taken up by the public.

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