caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* spurious warning? "polymorphic method not principal"
@ 2006-03-16 22:23 j h woodyatt
  2006-03-17  9:55 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: j h woodyatt @ 2006-03-16 22:23 UTC (permalink / raw)
  To: The Caml Trade

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>




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] spurious warning? "polymorphic method not principal"
  2006-03-16 22:23 spurious warning? "polymorphic method not principal" j h woodyatt
@ 2006-03-17  9:55 ` Jacques Garrigue
  0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2006-03-17  9:55 UTC (permalink / raw)
  To: jhw; +Cc: caml-list

From: j h woodyatt <jhw@conjury.org>

> > (* 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?   

No, this is a bug in the compiler. I'll try to fix it.

Jacques Garrigue


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-17  9:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-16 22:23 spurious warning? "polymorphic method not principal" j h woodyatt
2006-03-17  9:55 ` [Caml-list] " Jacques Garrigue

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).