From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 5BE91BBCA for ; Thu, 20 Mar 2008 16:42:26 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjgGAEEi4kfAXQIn/2dsb2JhbACCPTWndw X-IronPort-AV: E=Sophos;i="4.25,531,1199660400"; d="scan'208";a="10495689" Received: from concorde.inria.fr ([192.93.2.39]) by mail3-smtp-sop.national.inria.fr with ESMTP; 20 Mar 2008 16:42:27 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m2KFgJ17022719 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 20 Mar 2008 16:42:25 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlgBAOMi4kfRVciqlGdsb2JhbACCPTWOEgEBAQEJAwkJFJky X-IronPort-AV: E=Sophos;i="4.25,531,1199660400"; d="scan'208";a="24005638" Received: from wf-out-1314.google.com ([209.85.200.170]) by mail4-smtp-sop.national.inria.fr with ESMTP; 20 Mar 2008 16:42:24 +0100 Received: by wf-out-1314.google.com with SMTP id 26so1370933wfd.0 for ; Thu, 20 Mar 2008 08:42:22 -0700 (PDT) Received: by 10.142.47.6 with SMTP id u6mr1350888wfu.159.1206027742505; Thu, 20 Mar 2008 08:42:22 -0700 (PDT) Received: by 10.142.11.6 with HTTP; Thu, 20 Mar 2008 08:42:22 -0700 (PDT) Message-ID: <71767b800803200842v6ac988c8j5347c457e6a559de@mail.gmail.com> Date: Thu, 20 Mar 2008 11:42:22 -0400 From: "Ralph Douglass" To: "Jeremy Yallop" Subject: Re: [Caml-list] unused variable error with objects Cc: "Caml List" In-Reply-To: <47E26D74.8040109@ed.ac.uk> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2281_25266543.1206027742489" References: <71767b800803200640i291c837fkb7d36e06f1415ea9@mail.gmail.com> <47E26D74.8040109@ed.ac.uk> X-Miltered: at concorde with ID 47E285DB.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; syntax:01 foo:01 denotes:01 foo:01 bindings:01 syntax:01 denotes:01 bindings:01 W6:98 W6:98 wrote:01 wrote:01 incompatible:01 incompatible:01 caml-list:01 ------=_Part_2281_25266543.1206027742489 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Great, that does indeed give me exactly what I want. I guess I just got confused by the type annotation syntax, and for some reason I had the order wrong. Thanks again! On 3/20/08, Jeremy Yallop wrote: > > Ralph Douglass wrote: > > With labeled functions, I usually do something like ~snoo:_, but it does > > not work in this exampled with methods: > > --- > > class foo = object > > method bar ~(snoo : string):_ = () > > end;; > > > In this case the ':_' denotes a type annotation, using the "any-type" > expression '_'. You're declaring the return type of the method, as > you'll see if you change the annotation to something incompatible with > unit, such as > > class foo = object > method bar ~(snoo : string):int = () > end > > > > On a whim, I did the following, which surprisingly worked: > > > > class foo = object > > method bar ~(_snoo : string) = () > > end;; > > > This works because the "unused variables" warning is disabled for > variables which start with an underscore. It's a useful feature for > normal bindings but I don't think you should use it for labels, since it > changes the interface. > > > > Is there a solution to this? > > > I think the following is what you want: > > > class foo = object > method bar ~snoo:(_:string) = () > end > > > Jeremy. > -- Ralph ------=_Part_2281_25266543.1206027742489 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Great, that does indeed give me exactly what I want.  I guess I just got confused by the type annotation syntax, and for some reason I had the order wrong.

Thanks again!

On 3/20/08, Jeremy Yallop <jeremy.yallop@ed.ac.uk> wrote:
Ralph Douglass wrote:
> With labeled functions, I usually do something like ~snoo:_, but it does
> not work in this exampled with methods:
> ---
> class foo = object
>   method bar ~(snoo : string):_ = ()
> end;;


In this case the ':_' denotes a type annotation, using the "any-type"
expression '_'.  You're declaring the return type of the method, as
you'll see if you change the annotation to something incompatible with
unit, such as

    class foo = object
      method bar ~(snoo : string):int = ()
    end


> On a whim, I did the following, which surprisingly worked:
>
> class foo = object
>   method bar ~(_snoo : string) = ()
> end;;


This works because the "unused variables" warning is disabled for
variables which start with an underscore.  It's a useful feature for
normal bindings but I don't think you should use it for labels, since it
changes the interface.


> Is there a solution to this?


I think the following is what you want:


    class foo = object
      method bar ~snoo:(_:string) = ()
    end


Jeremy.



--
Ralph ------=_Part_2281_25266543.1206027742489--