Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Object-oriented access bottleneck
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nuutti Kotivuori <naked+caml@n...>
Subject: Re: [Caml-list] Object-oriented access bottleneck
Brian Hurt wrote:
> I don't think there can be.  Consider the function:
>
> let f c = c#foo 3 ;;
>
> In O'caml, this has type: < foo : int -> 'a; .. > -> 'a which
> basically means it accepts any object with a foo member function.
>
> So what happens if we define two classes, which don't relate to each
> other except each has a foo member function.  Only in one class foo
> is a virtual function, and in the second class foo is a non-virtual

Yes, I mentioned this in the mail (in the part that was snipped). It
does not work for the general case - however if we do know the exact
type, it could be done.

> A better alternative would be, I think, to spend a little time
> optimizing virtual function calls, so that they are faster.

Well sure, that will help and is a good idea in general. But it will
never allow for inlining of the function body into the calling
function, and as such will never solve the underlying problem.

-- Naked

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners