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
adding methods to object
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-04-01 (06:34)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] adding methods to object
From: "Jacques Le Normand" <>

> is it possible to add methods to an object?
> in other words, if an object has type <a:b,c:d>, is it possible to create an
> object of type <a:b,c:d,e:f> ?

No, you can only add methods to classes.
The only thing you can do with an object is build a wrapper object or
class, which forwards original methods to the base object:

let wrap o =
    method a = o#a
    method c = o#c
    method e = ...

Jacques Garrigue