Browse thread
[Caml-list] About polymorphic methods and recursive classes
[
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: | Sebastien Briais <sebastien.briais@e...> |
| Subject: | Re: [Caml-list] About polymorphic methods and recursive classes |
>
>
>># class virtual ['a] visitor =
>> object
>> method virtual caseNil : 'a
>> end
>> and virtual int_list =
>> object
>> method virtual visit : 'a.('a visitor -> 'a)
>> end
>> ;;
>>class virtual ['a] visitor : object method virtual caseNil : 'a end
>>class virtual int_list : object method virtual visit : 'a visitor ->
>>'a end
>>
>># class nil =
>> object
>> inherit int_list
>> method visit v = v#caseNil
>> end
>> ;;
>>This expression has type 'a visitor
>>It has no method caseNil
>>
>>
>
>it seems to work with class types :
>
>
ok, but it does not answer my question.
I am still puzzled by the answer of the interpreter which says me that
"v has type 'a visitor; It has no method caseNil"
although it has inferred just before that
"class virtual ['a] visitor : object method virtual caseNil : 'a end"
Moreover, it seems odd to me that it works with class types but not without.
These class types should be inferred by Ocaml, shouldn't they ? (and
they seems
to be correctly inferred in my example (in the first part of it))
So I ask again : how should I interpret the error message given by ocaml ?
Regards
Sébastien
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners