Browse thread
Ocaml compiler features
[
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: | David Baelde <david.baelde@g...> |
| Subject: | Re: [Caml-list] Ocaml compiler features |
On 1/13/07, Edgar Friendly <thelema314@gmail.com> wrote: > I understand that the let statement groups the following compound > expression into one statement for the then-clause, so it's a precedence > problem. Would it really be enough to raise the precedence of ; higher > than that of if/then? Is there any reason this hasn't been done already? It may be useful to note that some people might want to write code like: foo ; x <- if y then a else b ; bar ; In that example bar is really meant to be outside the if-then-else. OCaml has no such thing as statements, but only expressions. But let me use these words: you want a statement-level if-then-else with lower precedence than ";", it cannot be the same as this expression-level if-then-else with higher precedence than ";". If you're bored with begin/end a good solution might be to define a new construct using camlp4 instead of hacking the compiler. It's the good advice in general for syntax problems. my_if condition my_then foo ; x <- if y then a else b ; bar ; my_else etc Of course one wants better keywords than this. Finally, I'd made the closing of that new if mandatory, it seems clearer. Hope that helps. -- David