Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Michal Moskal <malekith@p...>
Subject: Re: [Caml-list] OCaml wishlist
On Tue, Oct 21, 2003 at 03:29:21PM +0100, Richard Jones wrote:
> 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. 

You can try guarded patterns. I have to admit that OCaml makes
imperative programming somewhat harder then it strictly have to. This is
however religious issue.

> 2. abstract data type syntactic sugar:
>    obj#call		      [	or:   obj->call ]
> 
>    is exactly equivalent to:
> 
>    M.call obj

let f a b c = a->add b c

What type does f have? 

-- 
: Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv
: When in doubt, use brute force. -- Ken Thompson : {E-,w}-- {b++,e}>+++ h

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