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
Re: [Caml-list] Width subtyping
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-05-31 (07:34)
From: David Allsopp <dra-news@m...>
Subject: RE: [Caml-list] Width subtyping
> Dario Teixeira wrote:
> > You are right.  I was probably too fixated on the OOP way of doing this,
> > translating record fields into object fields and the functions acting on
> > records into object methods.  Your solution, where record fields become object
> > methods and external functions act on objects that match a certain structure,
> > does solve the inconveniences I mentioned before.  But objects are still
> > a somewhat heavier solution, right?
> Heavier in terms of efficiency, or syntax?

My concern is the former. The extra two fields per "record" and the heavier runtime calls make them so systemically slower that (to me, at least) it just feels "wrong" to use objects just to achieve a little syntactic clarity and a small reduction in the amount of code written. Polymorphic variants (which use only slightly more memory than regular variant values) otherwise perform at the same speed as their normal counterparts.