* [Caml-list] Syntax errors with match and interface files @ 2005-07-21 22:42 Jonathan Roewen 2005-07-22 0:26 ` Stephane Glondu 2005-07-22 5:47 ` skaller 0 siblings, 2 replies; 3+ messages in thread From: Jonathan Roewen @ 2005-07-21 22:42 UTC (permalink / raw) To: caml-list Hi, I'm getting a curious syntax error: in my Key.mli file, I have: val kEnter: int; val kBksp: int; then, in Console.ml, I'm trying something like: 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 -> () but I get a syntax error at any match case with Key.xxx. I tried replacing with arbitrary numbers, and the errors at those lines disappear. Is this a problem with the ocaml[opt] compiler? Jonathan ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Syntax errors with match and interface files 2005-07-21 22:42 [Caml-list] Syntax errors with match and interface files Jonathan Roewen @ 2005-07-22 0:26 ` Stephane Glondu 2005-07-22 5:47 ` skaller 1 sibling, 0 replies; 3+ messages in thread From: Stephane Glondu @ 2005-07-22 0:26 UTC (permalink / raw) To: Jonathan Roewen; +Cc: caml-list 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. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Syntax errors with match and interface files 2005-07-21 22:42 [Caml-list] Syntax errors with match and interface files Jonathan Roewen 2005-07-22 0:26 ` Stephane Glondu @ 2005-07-22 5:47 ` skaller 1 sibling, 0 replies; 3+ messages in thread From: skaller @ 2005-07-22 5:47 UTC (permalink / raw) To: Jonathan Roewen; +Cc: caml-list [-- Attachment #1: Type: text/plain, Size: 404 bytes --] On Fri, 2005-07-22 at 10:42 +1200, Jonathan Roewen wrote: > Hi, > > I'm getting a curious syntax error: > > in my Key.mli file, I have: > > val kEnter: int; > val kBksp: int; Because of the curious semicolons .. which are infix sequencing operators used in expressions. val binding in an interface is not an expression.. -- John Skaller <skaller at users dot sourceforge dot net> [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-07-22 5:48 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-07-21 22:42 [Caml-list] Syntax errors with match and interface files Jonathan Roewen 2005-07-22 0:26 ` Stephane Glondu 2005-07-22 5:47 ` skaller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox