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=AWL 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 B5603BBCA for ; Thu, 20 Mar 2008 15:06:00 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqQFAOoL4kfAXQIm/2dsb2JhbACBWqhr X-IronPort-AV: E=Sophos;i="4.25,531,1199660400"; d="scan'208";a="10492422" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 20 Mar 2008 15:06:00 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m2KE5xGH002948 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 20 Mar 2008 15:06:00 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlULAJ8M4kdT9QHmWGdsb2JhbACBWo8gARYECQcXmRQ X-IronPort-AV: E=Sophos;i="4.25,531,1199660400"; d="scan'208";a="8614814" Received: from pop.bulldoghome.com (HELO bdmail1.accesst.com) ([83.245.1.230]) by mail2-smtp-roc.national.inria.fr with ESMTP; 20 Mar 2008 15:05:56 +0100 Received: from host-84-9-233-70.dslgb.com ([84.9.233.70] helo=[192.168.123.191]) by bdmail1.accesst.com with esmtpa (Exim 4.50) id 1JcLLz-0002Fm-Bd; Thu, 20 Mar 2008 14:02:48 +0000 Message-ID: <47E26D74.8040109@ed.ac.uk> Date: Thu, 20 Mar 2008 13:58:12 +0000 From: Jeremy Yallop User-Agent: Mozilla-Thunderbird 2.0.0.9 (X11/20080110) MIME-Version: 1.0 To: Ralph Douglass Cc: Caml List Subject: Re: [Caml-list] unused variable error with objects References: <71767b800803200640i291c837fkb7d36e06f1415ea9@mail.gmail.com> In-Reply-To: <71767b800803200640i291c837fkb7d36e06f1415ea9@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 47E26F47.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; foo:01 denotes:01 foo:01 bindings:01 wrote:01 incompatible:01 caml-list:01 functions:01 int:01 expression:02 declaring:02 underscore:02 annotation:02 annotation:02 variables:02 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.