* [Caml-list] OO Interface
@ 2002-01-17 20:34 Warp
2002-01-18 6:49 ` Jacques Garrigue
0 siblings, 1 reply; 3+ messages in thread
From: Warp @ 2002-01-17 20:34 UTC (permalink / raw)
To: OCaml
If I got a parametrized class like :
class p (x:int) (y:int) =
object(self)
val x = x
val y = y
method pos = (x,y)
rnd
How do I write the correct interface for this class ? I can't figure out how
to specify the parameters type.
I don't want to, but perhaps I have to use a Module ?
Thanks
Warp
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] OO Interface
2002-01-17 20:34 [Caml-list] OO Interface Warp
@ 2002-01-18 6:49 ` Jacques Garrigue
0 siblings, 0 replies; 3+ messages in thread
From: Jacques Garrigue @ 2002-01-18 6:49 UTC (permalink / raw)
To: warplayer; +Cc: caml-list
From: "Warp" <warplayer@free.fr>
> If I got a parametrized class like :
>
> class p (x:int) (y:int) =
> object(self)
> val x = x
> val y = y
> method pos = (x,y)
> rnd
>
> How do I write the correct interface for this class ? I can't figure out how
> to specify the parameters type.
Here is the interface, as the typechecker tells you,
class p :
int -> int -> object method pos : int * int val x : int val y : int end
You can directly write it in the .mli.
Or did you mean class type?
Actually, this automatically defines the following class type,
class type p =
object method pos : int * int val x : int val y : int end
Hope this helps,
Jacques Garrigue
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] OO Interface
@ 2002-01-17 22:31 #!Fì£é__1³~~ 0=2°
0 siblings, 0 replies; 3+ messages in thread
From: #!Fì£é__1³~~ 0=2° @ 2002-01-17 22:31 UTC (permalink / raw)
To: caml-list
the easiest way to do it is to simply assign
initial values to x and y:
# class p (x:int) (y:int) =
object(self)
val x = 0
val y = 0
method pos = (x,y)
end;;
class p : int -> int -> object method pos : int
* int val x : int val y : int end
# let x = new p 5 7;;
val x : p = <obj>
# x#pos;;
- : int * int = 0, 0
hope this helps....
file13
http://www.qlippoth.com/
---- Begin Original Message ----
From: "Warp" <warplayer@free.fr>
Sent: Thu, 17 Jan 2002 21:34:14 +0100
To: "OCaml" <caml-list@inria.fr>
Subject: [Caml-list] OO Interface
If I got a parametrized class like :
class p (x:int) (y:int) =
object(self)
val x = x
val y = y
method pos = (x,y)
rnd
How do I write the correct interface for this
class ? I can't figure out how
to specify the parameters type.
I don't want to, but perhaps I have to use a
Module ?
Thanks
Warp
-------------------
Bug reports: http://caml.inria.fr/bin/caml-
bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-
request@inria.fr Archives: http://caml.inria.fr
---- End Original Message ----
No 'Truth' until Silence!! The 777 Devils mail http://qlippoth.zzn.com
____________________________________________________________
Get your own FREE Web and POP E-mail Service in 14 languages at http://www.zzn.com.
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-01-18 7:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-17 20:34 [Caml-list] OO Interface Warp
2002-01-18 6:49 ` Jacques Garrigue
2002-01-17 22:31 #!Fì£é__1³~~ 0=2°
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox