[squeak-dev] Immutability (was Re: About String vs Symbols)

Eliot Miranda eliot.miranda at gmail.com
Tue Jul 29 20:24:49 UTC 2008


On Tue, Jul 29, 2008 at 1:03 PM, Janko Mivšek <janko.mivsek at eranova.si>wrote:

> Hi Eliot,
>
> Does that mean that you are introducing immutability in new Squeak VM you
> are working on? Well, that would be really nice!
>



I think that's up to the community.  There is a small performance hit (don't
have measurements to hand but would expect it to be in the 2% to 4% range).
 What I'd like to do is modify Slang so that one can mix and match
components to produce the VM you want.  In the StackVM I'm working on I
already have the ability to add a subclass that overrides methods in the
superclass so NewObjectMemory organizes the young generation differently to
ObjectMemory overriding a few methods.  It should be easy to extend this to
allow e.g. ImmutabilityInterpreter to override Interpreter and add
immutability without having to rewrite the entire Interpreter class.

Then we don't have to commit to immutablity.  People can experiment with it
and then try to persuade the community that its a good idea (I do think its
a good idea).

BTW, immutability involves primitive error codes and I will be introducing
primitive error codes, because the performance hit is essentially zero and
there is no backward compatibility issue (strange but true :) ).



>
> Janko
>
> Eliot Miranda wrote:
>
>>
>>
>> On Tue, Jul 29, 2008 at 9:21 AM, stephane ducasse <
>> stephane.ducasse at free.fr <mailto:stephane.ducasse at free.fr>> wrote:
>>
>>    Hello
>>
>>    I'm reading newspeak spec and I like the idea of immutable strings.
>>    Now what does it really bring to us?
>>
>>
>> Safety.  One can no longer overwrite literals or methods (or anything else
>> whose state you want to protect) accidentally.
>>
>> Expressive power.  One can use immutability as a write barrier in
>> orthogonal persistence or distribution schemes (and other things) .  One
>> marks an object as immutable to indicate that it is persistent or
>> distributed and its changes should be exported.  The immutability scheme
>> allows one to associate managers for specific objects that handle
>> NoModificationErrors on a per-object basis.  So if an object is immutable
>> and has an appropriate manager that manager can temporarily enable
>> immutablity for the object, allow the modification, communicate the
>> modification (e.g. to a database or remote image) and then re-enable
>> immutability.  The framework allows an object to have multiple managers.
>>  (This is all standard Squeak and very similar to the code I wrote for VW.
>>  The VM code is also available from Cadence).
>>
>>    Then does it mean that we could get rid of symbols
>>    immutability does not imply unique identity.
>>
>>
>> No.  As you point out Symbols are unique and so immutable strings don't
>> replace them.  But it is nice to have immutable Symbols.  e.g. try to do
>> this in your Squeak image:
>>    #class pvtAt: 1 put: 0 asCharacter
>> Scary :)
>>
>>
>>
>>    Stef
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>>
> --
> Janko Mivšek
> AIDA/Web
> Smalltalk Web Application Server
> http://www.aidaweb.si
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080729/26035092/attachment.htm


More information about the Squeak-dev mailing list