Version française
Home     About     Download     Resources     Contact us    
Browse thread
Execution time of class versus record
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Execution time of class versus record
On Sunday 24 June 2007 19:51:02 Arnaud Spiwack wrote:
> ...btw object coercion should never cost anything
> since they are merely type level tools...

Even in statically typed systems you might well want to shift work to run-time 
(e.g. specialization of all-float records/arrays) so I see no reason to 
expect coercion to be free.

> At runtime, I can't see anything to preven objects to be exactly records
> (with a bit of care taken during compilation for method names).

How can the current representation of records handle virtual method dispatch?

> John 
> Skaller's answer is not really convincing either, since the type of a
> value does not change the size of the value, having the same name
> associated to different types does not seem to me a good motivation.

I think this choice makes OCaml's object system more orthogonal to the rest of 
the language.

> Another lead is maybe something due to module compilation, the
> earlier idea might imply that each module has it's own namespace (it's
> the case for almost everything in OCaml, except, if I'm not mistaking,
> method names

and polymorphic variants.

> If it is the motivation for having a runtime 
> representation of objects different to that of records, the question
> that raises nex is: what is the motivation for not having
> module-specific namespaces for method names?

If I have two modules containing two classes and I want them to be related, 
how can you implement that with structurally-subtyped OO if method names are 
local to modules?

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
The OCaml Journal
http://www.ffconsultancy.com/products/ocaml_journal/?e