[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jacques Garrigue <garrigue@k...> |
| Subject: | Re: [Caml-list] classes and labels |
From: wester@ilt.fhg.de
> class myclass ?(n=0) () =
> object
> val nn = n;
> method get_nn = nn
> method clone (na: int) = let (mc: myclass) = new myclass ~n:na () in mc;
> end;;
>
> that produces the following error message in the toplevel:
>
> Characters 5-153:
> The expression "new myclass" has type ?n:int -> unit -> myclass
> but is used with type int -> unit -> myclass
What version of ocaml are you using ?
At least, I couldn't reproduce the problem with 3.01:
Objective Caml version 3.01
# class myclass ?(n=0) () =
object
val nn = n;
method get_nn = nn
method clone (na: int) = let (mc: myclass) = new myclass ~n:na () in mc;
end;;
class myclass :
?n:int ->
unit ->
object val nn : int method clone : int -> myclass method get_nn : int end
And this both with the -labels option on and off.
By the way, you don't need all these annotations in the clone method:
method clone na = new myclass ~n:na ()
Regards,
Jacques Garrigue
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr