Whither SmallScript? (was Re: Integer micro-benchmarks)
James A. Robertson
jarober at mail.com
Wed May 2 13:12:29 EDT 2001
Darren New wrote:
>
> James A. Robertson wrote:
> > > were wondering. And add or remove instance variables
> > > dynamically, too (I don't think that one is so easy in
> > > Smalltalk).
> >
> > Sure it is.
> > MyClass addInstVarName: 'foo'
> > MyClass removeInstVarName: 'foo'
>
> This is a little different from Python, tho.
>
> In smalltalk, addInstVarName adds the instance variable to the *class* and
> then updates all instances to now have that variable in them. (A relatively
> high-overhead operation, yes.) IIRC, it might also have to recompile some or
> all of the class code?
You recompile the subclasses (not their methods) if there are any
>
> In Python, you add instance variables to individual instances. Not all
> instances of the same class must have the same set of instance variables.
> (In one sense, all instances of a class have the same instance variables,
> but one of those instance variables is a dictionary mapping instance
> variable names to values, and the syntax makes this mostly invisible.)
>
> I think if you want to add an instance variable to all instances of a class,
> you need to write a loop to iterate over all those instances. I'm not sure
> whether you could find them.
>
> --
> Darren New / Senior MTS & Free Radical / Invisible Worlds Inc.
> San Diego, CA, USA (PST). Cryptokeys on demand.
> Invasion in chinese restaurant:
> ALL YOUR RICE ARE BELONG TO US!
--
James A. Robertson
Product Manager (Smalltalk), Cincom
jarober at mail.com
<Talk Small and Carry a Big Class Library>
More information about the Python-list
mailing list