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=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 207DEBBCA for ; Thu, 20 Mar 2008 14:57:45 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4BAEYK4keBrw8EiGdsb2JhbACRBAEBAQ8mmQ8 X-IronPort-AV: E=Sophos;i="4.25,531,1199660400"; d="scan'208";a="8614394" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 20 Mar 2008 14:57:45 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m2KDve5J017547 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 20 Mar 2008 14:57:44 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4BAEYK4keBrw8EiGdsb2JhbACRBAEBAQ8mmQ8 X-IronPort-AV: E=Sophos;i="4.25,531,1199660400"; d="scan'208";a="8614392" Received: from ext.lri.fr ([129.175.15.4]) by mail2-smtp-roc.national.inria.fr with ESMTP; 20 Mar 2008 14:57:44 +0100 Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id 81238A46D0; Thu, 20 Mar 2008 14:57:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lri.fr Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Zt1uG+dyZk2r; Thu, 20 Mar 2008 14:57:44 +0100 (CET) Received: from smtp.lri.fr (vhost3-23 [129.175.3.23]) by ext.lri.fr (Postfix) with ESMTP id 677E0A46CB; Thu, 20 Mar 2008 14:57:44 +0100 (CET) Received: from serveur9-10.lri.fr (serveur9-10 [129.175.9.10]) by smtp.lri.fr (Postfix) with ESMTP id 5C730E0537; Thu, 20 Mar 2008 14:57:44 +0100 (CET) Received: from localhost ([127.0.0.1] ident=signoles) by serveur9-10.lri.fr with esmtp (Exim 3.36 #1 (Debian)) id 1JcLH6-0006kq-00; Thu, 20 Mar 2008 14:57:44 +0100 Date: Thu, 20 Mar 2008 14:57:44 +0100 (CET) From: Julien Signoles To: Ralph Douglass Cc: Caml List Subject: Re: [Caml-list] unused variable error with objects In-Reply-To: <71767b800803200640i291c837fkb7d36e06f1415ea9@mail.gmail.com> Message-ID: References: <71767b800803200640i291c837fkb7d36e06f1415ea9@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 47E26D54.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; signoles:01 signoles:01 lri:01 foo:01 foo:01 ocamlc:01 -warn-error:01 compiles:01 caml-list:01 functions:01 string:02 string:02 objects:02 seems:03 let:03 > 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;; > > let biff = new foo;; > biff#bar ~snoo:"hi";; > -- > ocamlc -c -w Ae -warn-error Ae foo.ml > File "foo.ml", line 2, characters 15-19: > Warning Z: unused variable snoo. > > On a whim, I did the following, which surprisingly worked: > > class foo = object > method bar ~(_snoo : string) = () > end;; > > let biff = new foo;; > biff#bar ~_snoo:"hi";; > > And that compiles, which confused me. But I have to put the underbar into > the method call, which seems wrong. > Is there a solution to this? Try this: class foo = object method bar ~snoo:(_:string) = () end;; (new foo)#bar ~snoo:"hi";; -- Julien