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
objects as method arguments
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-05-02 (23:05)
From: micha <micha-1@f...>
Subject: objects as method arguments

I want to have the following:

class c = object
 inherit base
 method m (arg : #base) = arg#do_something

this gives an error. Is the only way to get this working to write it
that way?

class c = object
 inherit base
 method m: 'a.  (#base as 'a) -> unit  = fun arg -> arg#do_something

If  I have more of such methods, that looks rather ugly. Also I
don't want to cast the argument-object to the baseclass type

do I overlook something?