caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: j h woodyatt <jhw@conjury.org>
To: The Caml Trade <caml-list@inria.fr>
Subject: spurious warning? "polymorphic method not principal"
Date: Thu, 16 Mar 2006 14:23:49 -0800	[thread overview]
Message-ID: <B0DFEE75-13D5-4D9E-BCDB-96EA99E1FFAD@conjury.org> (raw)

everyone--

Please, consider the following test case:

> (* test.ml *)
> class alfa = object(_:'self)
>   method x: 'a. ('a, out_channel, unit) format -> 'a = Printf.printf
> end
>
> class bravo a = object
>   val y: alfa = (a :> alfa)
>   initializer y#x "bravo initialized"
> end
>
> class charlie a = object
>   inherit bravo a
>   initializer y#x "charlie initialized"
> end

$ ocamlc -principal -o test test.ml
File "test.ml", line 13, characters 14-17:
Warning X: this use of a polymorphic method is not principal.

It warns about the use of the polymorphic method on the object in the  
membership of the base class, but only when it's invoked from the  
derived class.  This confuses me.  Is this a bug in my code?   
(Perhaps, the word "principal" in this context doesn't mean what I  
think it means.)

Or is it a bug in the compiler?  If it isn't a bug in the compiler,  
could someone please explain to me why my program produced this  
warning?  Thank you very much.


—
j h woodyatt <jhw@conjury.org>




             reply	other threads:[~2006-03-17  8:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-16 22:23 j h woodyatt [this message]
2006-03-17  9:55 ` [Caml-list] " Jacques Garrigue

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=B0DFEE75-13D5-4D9E-BCDB-96EA99E1FFAD@conjury.org \
    --to=jhw@conjury.org \
    --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).