caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* a syntax error that I don't get
@ 2010-11-18 14:59 Philippe Strauss
  2010-11-19  7:00 ` [Caml-list] " bluestorm
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Strauss @ 2010-11-18 14:59 UTC (permalink / raw)
  To: caml-list

Hello caml'ers

This one is short, I'm writting a signal handler:

205: let sig_exit () =
206:    Unix.kill !chpid Sys.sigterm ;
207:    match (Unix.waitpid [] !chpid) with
208:    | pid, Unix.WSIGNALED (Sys.sigterm) -> log `LOG_NOTICE "child 
terminated by parent"
209:    | pid, pstat -> log `LOG_ERR "child asked to terminate by 
parent, but unexpected process status received"

and compilation chokes on:

philou@air:~/mysrc/deconvolution/jackond$ make
ocamlfind opt -thread -package 
unix,threads,netsys,netstring,netplex,rpc,equeue,jack,str,syslog -c 
patcher.ml -o patcher.cmx
File "patcher.ml", line 208, characters 28-35:
Error: Syntax error
make: *** [patcher.cmx] Error 2

replacing Sys.sigterm by -11 or signumber, it compiles fine.

I don't get it.

It's using ocaml 3.12 of godi, on osx 10.6.5, x86_64




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] a syntax error that I don't get
  2010-11-18 14:59 a syntax error that I don't get Philippe Strauss
@ 2010-11-19  7:00 ` bluestorm
  0 siblings, 0 replies; 2+ messages in thread
From: bluestorm @ 2010-11-19  7:00 UTC (permalink / raw)
  To: Philippe Strauss; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1683 bytes --]

In pattern position you must write patterns, not expressions; this is a
different syntaxic class that, in particular, doesn't have any Module.foo
syntax.
Writing bound variable in pattern position and hoping that it will do an
equality test is a classic mistake. Even if you did "open Sys;;" then match
on "sigterm", it wouldn't do what you want. A correct way to do it:

  | pid, Unix.WSIGNALED sig when sig = Sys.sigterm -> ...

On Thu, Nov 18, 2010 at 3:59 PM, Philippe Strauss <philou@philou.ch> wrote:

> Hello caml'ers
>
> This one is short, I'm writting a signal handler:
>
> 205: let sig_exit () =
> 206:    Unix.kill !chpid Sys.sigterm ;
> 207:    match (Unix.waitpid [] !chpid) with
> 208:    | pid, Unix.WSIGNALED (Sys.sigterm) -> log `LOG_NOTICE "child
> terminated by parent"
> 209:    | pid, pstat -> log `LOG_ERR "child asked to terminate by parent,
> but unexpected process status received"
>
> and compilation chokes on:
>
> philou@air:~/mysrc/deconvolution/jackond$ make
> ocamlfind opt -thread -package
> unix,threads,netsys,netstring,netplex,rpc,equeue,jack,str,syslog -c
> patcher.ml -o patcher.cmx
> File "patcher.ml", line 208, characters 28-35:
> Error: Syntax error
> make: *** [patcher.cmx] Error 2
>
> replacing Sys.sigterm by -11 or signumber, it compiles fine.
>
> I don't get it.
>
> It's using ocaml 3.12 of godi, on osx 10.6.5, x86_64
>
>
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 2511 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-19  7:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-18 14:59 a syntax error that I don't get Philippe Strauss
2010-11-19  7:00 ` [Caml-list] " bluestorm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).