English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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?