caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Classes and memory foodprint + speed
@ 2010-12-26 13:57 Goswin von Brederlow
  0 siblings, 0 replies; only message in thread
From: Goswin von Brederlow @ 2010-12-26 13:57 UTC (permalink / raw)
  To: caml-list

Hi,

I want my classes to have some "variables" and there seem to be multiple
ways to do this. So I'm wondering what the actual difference is for the
memory foodprint and speed. So lets look at a trivial example:

# class foo (init_x : int) = object val x = init_x method get_x = x end
  class bar (init_x : int) (init_y : int) = object inherit foo init_x
val y = init_y method get_y = y end
  let t = new bar 1 2;;

  class foo : int -> object val x : int method get_x : int end
class bar :
  int ->
  int ->
  object val x : int val y : int method get_x : int method get_y : int end
val t : bar = <obj>


# class foo (x : int) = object method get_x = x end
  class bar (x : int) (y : int) = object inherit foo x method get_y = y
end
  let t = new bar 1 2;;

  class foo : int -> object method get_x : int end
class bar : int -> int -> object method get_x : int method get_y : int end
val t : bar = <obj>


So what are the differences between the two? How are they represented in
memory and how does that affect speed? Does it make sense to have "val
x" if it isn't mutable?

MfG
        Goswin

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-12-26 13:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-26 13:57 [Caml-list] Classes and memory foodprint + speed Goswin von Brederlow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).