From: "Ralph Douglass" <ralph@grayskies.net>
To: "Jeremy Yallop" <jeremy.yallop@ed.ac.uk>
Cc: "Caml List" <caml-list@inria.fr>
Subject: Re: [Caml-list] unused variable error with objects
Date: Thu, 20 Mar 2008 11:42:22 -0400 [thread overview]
Message-ID: <71767b800803200842v6ac988c8j5347c457e6a559de@mail.gmail.com> (raw)
In-Reply-To: <47E26D74.8040109@ed.ac.uk>
[-- Attachment #1: Type: text/plain, Size: 1355 bytes --]
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
[-- Attachment #2: Type: text/html, Size: 2023 bytes --]
prev parent reply other threads:[~2008-03-20 15:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-20 13:40 Ralph Douglass
2008-03-20 13:57 ` [Caml-list] " Julien Signoles
2008-03-20 13:58 ` Jeremy Yallop
2008-03-20 15:42 ` Ralph Douglass [this message]
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=71767b800803200842v6ac988c8j5347c457e6a559de@mail.gmail.com \
--to=ralph@grayskies.net \
--cc=caml-list@inria.fr \
--cc=jeremy.yallop@ed.ac.uk \
/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).