2014-10-27 16:22 GMT+01:00 Cl�ment Bera <bera.clement@gmail.com>:
Hey guys,

I was discussing about methods like that with Marcus:

MyClass>>foo
#(false) first�
ifFalse: [�
'first call since compilation' logCr.�
#(false) at: 1 put: true ]
ifTrue: [ 'other calls' logCr ]

What, you can do that?

DoIt:
4 timesRepeat: [MyClass new foo ]

Transcript:
'first call since compilation'
'other calls'
'other calls'
'other calls'

In the sista image/VM, we are most probably going with Eliot to implement a slow path when you edit the literal of a method (deoptimizing the method) so we can consider that the literals are immutable in the generic case (and if it's not true, execution falls back to a slow path).

But I was thinking, does it worth it to implement the slow path ?�
Couldn't we just put literals as immutable all the time ?

I would do that, yes.
The methods as the one shown before would not work any more. But does someone use it ?

I could imagine cases where, in very tight memory situations or with very very large literals, we could make use of modifying literals. But I'm not sure this is a significant requirement, or that it couldn't be considered if there is a significant (and rich) use case to fund the development of the slow path.

Is there a critic rule catching that sort of thing? That we could run on Squeaksource / Smalltalkhub?

Thierry

...