* [Caml-list] errors compiling thrift-generated code
@ 2011-03-18 14:29 Joel Reymont
2011-03-18 14:45 ` [Caml-list] " Joel Reymont
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Joel Reymont @ 2011-03-18 14:29 UTC (permalink / raw)
To: caml-list
Folks,
Any suggestions on what's going on here?
https://gist.github.com/876154
The error is at the very bottom.
This is code auto-generated by Apache Thrift.
Thanks, Joel
--------------------------------------------------------------------------
- for hire: mac osx device driver ninja, kernel extensions and usb drivers
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Caml-list] Re: errors compiling thrift-generated code
2011-03-18 14:29 [Caml-list] errors compiling thrift-generated code Joel Reymont
@ 2011-03-18 14:45 ` Joel Reymont
2011-03-18 14:47 ` [Caml-list] " Niki Yoshiuchi
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Joel Reymont @ 2011-03-18 14:45 UTC (permalink / raw)
To: Joel Reymont; +Cc: caml-list
Changing the copy method to this
method copy =
let _new = (Oo.copy self:> #document) in
_new
or this:
method copy : document =
let _new = Oo.copy self in
_new
gives the error at the very bottom of the gist [1], i.e. "Self type cannot escape its class"
Thanks, Joel
[1] https://gist.github.com/876154
--------------------------------------------------------------------------
- for hire: mac osx device driver ninja, kernel extensions and usb drivers
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] errors compiling thrift-generated code
2011-03-18 14:29 [Caml-list] errors compiling thrift-generated code Joel Reymont
2011-03-18 14:45 ` [Caml-list] " Joel Reymont
@ 2011-03-18 14:47 ` Niki Yoshiuchi
2011-03-18 14:52 ` Joel Reymont
[not found] ` <AANLkTikj278tWdB284C7E7ZQ4-PaynNCk8eCzf=QXn-0@mail.gmail.com>
2011-03-18 14:59 ` Guillaume Yziquel
3 siblings, 1 reply; 7+ messages in thread
From: Niki Yoshiuchi @ 2011-03-18 14:47 UTC (permalink / raw)
To: caml-list
Apologies if you receive this twice, I accidentally hit reply instead
of reply all.
The problem appears to be related to the problem that self is
dynamically bound at invocation (as objects can be extended by
subclasses). The details are outlined here:
http://caml.inria.fr/pub/docs/manual-ocaml/manual005.html#toc20
You'll noticed that if you declare an object with a reference to self
its type is:
class myclass : object ('a) .... : ;a end
In other words, self is of type 'a and not type myclass.
The easiest way to fix your problem is to change the interface so that:
method copy : document
becomes:
method copy : 'a
You should also file a bug report with the Thrift developers.
-Niki Yoshiuchi
On Fri, Mar 18, 2011 at 10:29 AM, Joel Reymont <joelr1@gmail.com> wrote:
> Folks,
>
> Any suggestions on what's going on here?
>
> https://gist.github.com/876154
>
> The error is at the very bottom.
>
> This is code auto-generated by Apache Thrift.
>
> Thanks, Joel
>
> --------------------------------------------------------------------------
> - for hire: mac osx device driver ninja, kernel extensions and usb drivers
> ---------------------+------------+---------------------------------------
> http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
> ---------------------+------------+---------------------------------------
>
>
>
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] errors compiling thrift-generated code
2011-03-18 14:47 ` [Caml-list] " Niki Yoshiuchi
@ 2011-03-18 14:52 ` Joel Reymont
0 siblings, 0 replies; 7+ messages in thread
From: Joel Reymont @ 2011-03-18 14:52 UTC (permalink / raw)
To: Niki Yoshiuchi; +Cc: caml-list
Niki,
On Mar 18, 2011, at 3:47 PM, Niki Yoshiuchi wrote:
> The easiest way to fix your problem is to change the interface so that:
>
> method copy : document
>
> becomes:
>
> method copy : 'a
It appears that I also need object ('a) in the mli, e.g.
open Thrift
class document :
object ('a)
...
method copy : 'a
method write : Protocol.t -> unit
end
Thanks a lot for your help!
--------------------------------------------------------------------------
- for hire: mac osx device driver ninja, kernel extensions and usb drivers
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <AANLkTikj278tWdB284C7E7ZQ4-PaynNCk8eCzf=QXn-0@mail.gmail.com>]
* Re: [Caml-list] errors compiling thrift-generated code
[not found] ` <AANLkTikj278tWdB284C7E7ZQ4-PaynNCk8eCzf=QXn-0@mail.gmail.com>
@ 2011-03-18 14:50 ` Joel Reymont
0 siblings, 0 replies; 7+ messages in thread
From: Joel Reymont @ 2011-03-18 14:50 UTC (permalink / raw)
To: Niki Yoshiuchi; +Cc: caml-list
> The easiest way to fix your problem is to change the interface so that:
>
> method copy : document
>
> becomes:
>
> method copy : 'a
I changed copy in the mli but it doesn't seem to work.
Error: The implementation src/Hello_types.ml
does not match the interface src/hello_types.cmi:
Class declarations do not match:
class document :
object ('a)
val mutable _docname : string option
val mutable _page : int option
val mutable _username : string option
method copy : 'a
method get_docname : string option
method get_page : int option
method get_username : string option
method grab_docname : string
method grab_page : int
method grab_username : string
method reset_docname : unit
method reset_page : unit
method reset_username : unit
method set_docname : string -> unit
method set_page : int -> unit
method set_username : string -> unit
method unset_docname : unit
method unset_page : unit
method unset_username : unit
method write : Thrift.Protocol.t -> unit
end
does not match
class document :
object
method copy : 'a
method get_docname : string option
method get_page : int option
method get_username : string option
method grab_docname : string
method grab_page : int
method grab_username : string
method reset_docname : unit
method reset_page : unit
method reset_username : unit
method set_docname : string -> unit
method set_page : int -> unit
method set_username : string -> unit
method unset_docname : unit
method unset_page : unit
method unset_username : unit
method write : Thrift.Protocol.t -> unit
end
The method copy has type
< copy : 'a; get_docname : string option; get_page : int option;
get_username : string option; grab_docname : string;
grab_page : int; grab_username : string; reset_docname : unit;
reset_page : unit; reset_username : unit;
set_docname : string -> unit; set_page : int -> unit;
set_username : string -> unit; unset_docname : unit;
unset_page : unit; unset_username : unit;
write : Thrift.Protocol.t -> unit; .. >
as 'a
but is expected to have type 'b. 'b
Command exited with code 2.
--------------------------------------------------------------------------
- for hire: mac osx device driver ninja, kernel extensions and usb drivers
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] errors compiling thrift-generated code
2011-03-18 14:29 [Caml-list] errors compiling thrift-generated code Joel Reymont
` (2 preceding siblings ...)
[not found] ` <AANLkTikj278tWdB284C7E7ZQ4-PaynNCk8eCzf=QXn-0@mail.gmail.com>
@ 2011-03-18 14:59 ` Guillaume Yziquel
2011-03-18 15:06 ` Joel Reymont
3 siblings, 1 reply; 7+ messages in thread
From: Guillaume Yziquel @ 2011-03-18 14:59 UTC (permalink / raw)
To: Joel Reymont; +Cc: caml-list
Le Friday 18 Mar 2011 à 15:29:12 (+0100), Joel Reymont a écrit :
> Folks,
>
> Any suggestions on what's going on here?
>
> https://gist.github.com/876154
>
> The error is at the very bottom.
>
> This is code auto-generated by Apache Thrift.
>
> Thanks, Joel
Can't say for sure, but I managed to have similar code compiling fine:
https://github.com/yziquel/OCaml-MPI/blob/master/datatype.p4.ml#L208
https://github.com/yziquel/OCaml-MPI/blob/master/datatype.p4.sig.mli#L45
I'd say: Try building class types first. But it's only a vague
impression I have when I try to recall how my code was built. Perhaps
changing the class in your .mli to have the method copy of type 'self?
The basic idea is that if you inherit from the class document, 'self
then denotes the derived class. That may be it. To my knowledge, there
isn't really a way to have classes as 'final' other than to use a
type my_class = private < some oo stuff here > construct, where you can
substitute 'self (which does not have any meaning in such a type
declaration) by my_class.
But it's all rather vague memories.
--
Guillaume Yziquel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-03-18 15:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-18 14:29 [Caml-list] errors compiling thrift-generated code Joel Reymont
2011-03-18 14:45 ` [Caml-list] " Joel Reymont
2011-03-18 14:47 ` [Caml-list] " Niki Yoshiuchi
2011-03-18 14:52 ` Joel Reymont
[not found] ` <AANLkTikj278tWdB284C7E7ZQ4-PaynNCk8eCzf=QXn-0@mail.gmail.com>
2011-03-18 14:50 ` Joel Reymont
2011-03-18 14:59 ` Guillaume Yziquel
2011-03-18 15:06 ` Joel Reymont
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox