Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Allow declaring classes "final" so self type has no type variables?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-09-11 (05:10)
From: james woodyatt <jhw@w...>
Subject: Re: [Caml-list] Allow declaring classes "final" so self type has no type variables?
On Tuesday, Sep 10, 2002, at 17:16 US/Pacific, Tim Freeman wrote:
> Well, I actually wanted the class to be final so its "self" didn't
> have to be polymorphic while it was being defined.

Well that's problematic, of course.  The reason class types are harder 
to use than record types is basically the same reason that polymorphic 
variant types are harder to use than regular variant types.

Perhaps someone with deeper knowledge of the issue will comment on 
whether and how it would cause problems if the self type in a class 
body could be unified with a closed object type.

> It's harder to get the types to work out when some of the type 
> variables running around are useless.

I have a technique for avoiding this kind of trouble.  Don't use class 
types where record types and/or functors are sufficient.  Keep class 
types simple, and use signatures to hide internals.  When subtyping 
without method inheritance is all you need, consider using functions 
and abstract types with polymorphic variants as phantom type parameters.

There's a lot you can do with Caml without using the 'object' keyword.  
Use classes only when all other language facilities are insufficient.

> No big deal, though.

Okay.  Hope I've been helpful anyway.

j h woodyatt <>
markets are only free to the people who own them.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: