From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id E3260BC57 for ; Fri, 19 Nov 2010 08:00:49 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuABALev5UzRVdivkGdsb2JhbACUJoYpAYgBCBUBAQEBCQkMBxEDH6JRiWKCGIUWLohZAQEDBYVGBIFciH6JKw X-IronPort-AV: E=Sophos;i="4.59,221,1288566000"; d="scan'208";a="79619339" Received: from mail-qy0-f175.google.com ([209.85.216.175]) by mail4-smtp-sop.national.inria.fr with ESMTP; 19 Nov 2010 08:00:49 +0100 Received: by qyk31 with SMTP id 31so313632qyk.6 for ; Thu, 18 Nov 2010 23:00:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:sender:received :in-reply-to:references:from:date:x-google-sender-auth:message-id :subject:to:cc:content-type; bh=+fwI4/jpAFs0ieFErD9ZkF4VvshTUpjqd90+WXKWHFk=; b=X12lVMJkzQK64jNwU+iB8c+hGSzYri5EYqjfrXXrQsvWxmvAVNRju482NgeT0RtdGW +MrWrBH10AjnT4LgRNPjyJwFR+X3n7YLKFpiezmXOvNGlvbeWAELsCWmEgJKCthUJZbf t7OqeP9yDM8iOdzH0VDH2grpLCIF1bPTP5Qc4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; b=X+pHWLR8Hrti/QYPgJ1yWnFEFt8a07LeN0oUnw0wE1hM/u/Qi7+3JJwlZ3bQIDDQ/k hsDghEvXBLLa+oQoD3bgWD46h9gGKwAhcyvd4sRCDe+1VeLuToU7+T582AwBVfzxtMpB A6zpMwDNbv34MI6C0ys0UAKwvGY+nOPHICxL0= Received: by 10.229.75.3 with SMTP id w3mr1433962qcj.296.1290150047186; Thu, 18 Nov 2010 23:00:47 -0800 (PST) MIME-Version: 1.0 Sender: gabriel.scherer@gmail.com Received: by 10.229.253.135 with HTTP; Thu, 18 Nov 2010 23:00:26 -0800 (PST) In-Reply-To: <4CE53F3B.7080200@philou.ch> References: <4CE53F3B.7080200@philou.ch> From: bluestorm Date: Fri, 19 Nov 2010 08:00:26 +0100 X-Google-Sender-Auth: O6OLyRmfFokt8_FsuUDZfNsJptg Message-ID: Subject: Re: [Caml-list] a syntax error that I don't get To: Philippe Strauss Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=00163646c12e45002304956277a9 X-Spam: no; 0.00; syntax:01 foo:01 syntax:01 sigterm:01 sig:01 sig:01 sigterm:01 waitpid:01 compilation:01 ocamlfind:01 -thread:01 -package:01 netstring:01 syslog:01 patcher:01 --00163646c12e45002304956277a9 Content-Type: text/plain; charset=ISO-8859-1 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 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 > --00163646c12e45002304956277a9 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable In pattern position you must write patterns, not expressions; this is a dif= ferent syntaxic class that, in particular, doesn't have any Module.foo = syntax.
Writing bound variable in pattern position and hoping that it w= ill do an equality test is a classic mistake. Even if you did "open Sy= s;;" then match on "sigterm", it wouldn't do what you wa= nt. A correct way to do it:

=A0=A0| pid, Unix.WSIGNALED sig when sig =3D Sys.sigter= m -> ...

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 () =3D
206: =A0 =A0Unix.kill !chpid Sys.sigterm ;
207: =A0 =A0match (Unix.waitpid [] !chpid) with
208: =A0 =A0| pid, Unix.WSIGNALED (Sys.sigterm) -> log `LOG_NOTICE "= ;child terminated by parent"
209: =A0 =A0| 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,eq= ueue,jack,str,syslog -c pat= cher.ml -o patcher.cmx
File "patcher.ml&q= uot;, 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.in= ria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--00163646c12e45002304956277a9--