Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 18, 2003 Size of a class | ||||
---|---|---|---|---|
| ||||
How can I find the size of a class? "Object o; return o.size;" doesn't work. It returns the size of the reference. A '.length' field in ClassInfo would be useful (or a '.length' property for classes). I need this because I would like to write a function which returns a byte[] which contains the contents of the class. We'd have to decide if that variable should include the classinfo pointer and the "monitor" (what is this "monitor" exactly?). |
October 18, 2003 Re: Size of a class | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dario | Can't you do "Object.size" ? That's the problem with references. IMO they should act as if they actually *are* the object they refer to, in all respects except assignment. I would expect your example "Object o; return o.size;" to return the same thing as "return Object.size;" There are a whole bunch of things that would be nice to have in the ClassInfo... Sean "Dario" <supdar@yahoo.com> wrote in message news:bmrc5d$16c3$2@digitaldaemon.com... > How can I find the size of a class? > "Object o; return o.size;" doesn't work. It returns the size of the > reference. > A '.length' field in ClassInfo would be useful (or a '.length' property for > classes). |
October 19, 2003 Re: Size of a class | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dario | "Dario" <supdar@yahoo.com> wrote in message news:bmrc5d$16c3$2@digitaldaemon.com... > How can I find the size of a class? > "Object o; return o.size;" doesn't work. It returns the size of the > reference. > A '.length' field in ClassInfo would be useful (or a '.length' property for > classes). > > I need this because I would like to write a function which returns a byte[] > which contains the contents of the class. > We'd have to decide if that variable should include the classinfo pointer > and the "monitor" (what is this "monitor" exactly?). The size of a class can be obtained from: Object foo; foo.classinfo.init.length; |
Copyright © 1999-2021 by the D Language Foundation