caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Ralph Douglass" <ralph@grayskies.net>
To: "Caml List" <caml-list@inria.fr>
Subject: unused variable error with objects
Date: Thu, 20 Mar 2008 09:40:35 -0400	[thread overview]
Message-ID: <71767b800803200640i291c837fkb7d36e06f1415ea9@mail.gmail.com> (raw)

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

I'm a little confused by some code that I'm trying to compile some code with
"-w Ae -warn-error Ae".

Below is an examle:

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

let biff = new foo;;
biff#bar ~snoo:"hi";;

When I compile it (ocamlc -c -w Ae -warn-error Ae foo.ml), as expected, I
get:
File "foo.ml", line 2, characters 15-19:
Warning Z: unused variable snoo.

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?

I'm running 3.10.1, from godi.

Thanks!

-- 
Ralph

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

             reply	other threads:[~2008-03-20 13:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-20 13:40 Ralph Douglass [this message]
2008-03-20 13:57 ` [Caml-list] " Julien Signoles
2008-03-20 13:58 ` Jeremy Yallop
2008-03-20 15:42   ` Ralph Douglass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=71767b800803200640i291c837fkb7d36e06f1415ea9@mail.gmail.com \
    --to=ralph@grayskies.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).