Version française
Home     About     Download     Resources     Contact us    
Browse thread
ocaml+twt v0.90
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ingo Bormuth <ibormuth@e...>
Subject: Re: [Caml-list] ocaml+twt v0.90
On 2007-01-16 15:48, Mike Lin wrote:
> This version introduces a major backwards-incompatible change: the
> eradication of "in" from let expressions, and the need to indent the let
> body (as suggested by the F# lightweight syntax). 

I downloaded the new version some day ago and immediately fell in love
with the compact syntax. In my opinion it feels much more natural.
I especially realized that it took me more effort to convert old
ocaml+twt code (lots of semantically relevant indentation changes) then
it did to convert vanilla ocaml code (essentially s/ *\( in\|;\)$//g
plus some optional parentheses removal).

> I was hesitant to introduce this feature because it's extra hackish in
> implementation (even moreso than the rest of this house of cards). It also
> removes some programmer freedom, because you cannot have the let body on the
> same line as the let, and you cannot have a statement sequentially following
> the let, outside the scope of the binding. 

A let body beginning in the first line is no problem if you add an
additional semicolon:

let print x y = print_string x ;   (* <-- note the semicolon *)
  print_string " "
  print_string y
print "Hello" "World"


If you need a function in private scope you can easily declare and call 
it inside a 'let _ =' block:

let x = 5
printf "%d\n" x
let _ =
  let y = x+1
  printf "%d\n" y
printf "no y here"


I ran into some minor problems due to ocaml+twt not recognizing the
object related syntax. As I personally use it only in rare cases, I
ended up with just putting the critical section in one long line.

I suggest to implement the '#light' pragma (as in f#) which would allow 
to swith on and off indentation awareness on the fly. This would also 
enable me to replace all ocaml compilers by wrappers calling ocaml+twt
implicitly. If you want I can prepare a little patch.

Thanks for your effort -- keep going on

  Ingo



-- 
Ingo Bormuth, voicebox & fax: +49-(0)-12125-10226517
public key 86326EC9, http://ibormuth.efil.de/contact