Browse thread
[Caml-list] Syntax errors with match and interface files
-
Jonathan Roewen
- Stephane Glondu
- skaller
[
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: | Stephane Glondu <Stephane.Glondu@c...> |
| Subject: | Re: [Caml-list] Syntax errors with match and interface files |
Hi, Jonathan Roewen wrote: > I'm getting a curious syntax error: > > [...] > > try > let put c = putch c; Queue.add c buffer in > match char_code with > | Key.kEnter -> put '\n' > | Key.kBksp -> put '\b' > | ch -> put (Key.to_char ch) > with Key.Not_printable -> () You cannot use defined variables as patterns (this is a common mistake). Variables appearing in a pattern are always bound to (parts) of the matched value. Something close to what you want would be : try let put c = putch c; Queue.add c buffer in match char_code with | ch when ch = Key.kEnter -> put '\n' | ch when ch = Key.kBksp -> put '\b' | ch -> put (Key.to_char ch) with Key.Not_printable -> () Stephane Glondu.