Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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
end;;

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
end;;

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
everytime...

do I overlook something?

cheers
 Michael