siguctua at gmail.com
Wed Jan 2 20:20:22 UTC 2008
On 02/01/2008, Klaus D. Witzel <klaus.witzel at cobss.com> wrote:
> On Wed, 02 Jan 2008 19:33:11 +0100, Igor Stasenko wrote:
> > On 02/01/2008, tim Rowledge <tim at rowledge.org> wrote:
> >> On 2-Jan-08, at 10:09 AM, Tony Garnock-Jones wrote:
> >> >
> >> >
> >> > Then I went looking. CompiledMethod is a direct subclass of ByteArray,
> >> > and has no instance variables.
> >> Yes, there have been plans to fix that for years but the work to do
> >> (what was once a simple change) is sufficiently complicated by traits,
> >> existing .pr files, tool related hacks and so on that it has become a
> >> major change that would require considerable resources. I tried again
> >> last year but it just grew into too much work.
> > Btw, this is one of the biggest things what i dislike in squeak.
> Are you aware of the consequences of such dislikeness? :) CompiledMethod
> has a dozen or so accessors which, to the average Smalltalk developer are
> "gettable" instance variables (some are even "settable").
> Encapsulation rules! :)
> You dislike accessors? :) Try adding a new one to CompiledMethod. Still
> dislike accessors ? :)
Yes, it is. But if you know, compiled methods are well-known objects
handled by VM.
The current format of a CompiledMethod is as follows:
header (4 bytes)
literals (4 bytes each)
now, suppose you want to add new field, called 'docs' or whatever.
Where would you put it?
- In literals? Good. Then you need to reserve a literal with a proper
index for it? And this will interfere with FFI/External primitive
- In trailer bytes (after bytecode) - then you interfere with
reference to source code. Also, your reference will be not visible by
Is there places left, where you can reserve a slot and put a reference
to object in it?
You can write thousands of accessors, but without having something
which you can access to. :)
And now, think what if we change compiled method to have any (by
subclassing) number of named vars, and bytecode as indexed vars. Then
each thing will find own place to live and will not interfere with
others, and you don't need a black magic in GC to handle compiled
methods differently than other objects.
Igor Stasenko AKA sig.
More information about the Squeak-dev