[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is an object?



Quoting Jerzy Karczmarczuk:
> Is there a way to extract from an instance of a class 
> *all* its IVARs: names, and related values? 
> 
> Some kind of association table should exist somewhere.
> 
> I might consider looking into the implementation (object.c ??), 
> but perhaps there is a hidden access to it directly from Scheme?

There's not currently a way to access this information from Scheme.
(Also, MzScheme doesn't have any hidden features - only hidden bugs!)

Note, however, that in the source distribution's plt/tests/mred, you
can find a file called "classhack.c". It defines an extension to return
all of the ivar names in a class.

I wish I could remember why I was previously opposed to adding this
function to MzScheme. At the moment, I see no reason not to add
`interface->ivar-names' for 102. (Combined with `class->interface', you
could get all the names from a class.)

I worry that there might have been a good reason to leave the function
out, but maybe the reason has gone away. I'll keep thinking about it,
just in case, but it's hard to imagine that `ivar-in-interface?' would
be ok while `interface->ivar-names' would be bad.

> The compiled, binary code of MrEd contains several dozens, perhaps
> more than a hundred occurrences of the string "ivar/proc". I wonder
> why...

Paul explained what `ivar/proc' is. The reason it shows up so much in
the binary is:

  1) The binary contains embedded bytecodes to implement parts of the
     GUI classes.

  2) I broke an optimization in the bytecode compiler in version 101.
     The optimization replaces names symbols (such as `#%ivar/proc')
     with indices. This has been fixed for version 102.

Matthew