oh, you were talking about how te VM views the object, I was thinking in terms of how the compiler sees the text.
So I'm talking about literals "syntax". Thanks anyway for the "trick" :) On 27/04/2018 16:34, Clément Bera wrote: > The guy who asked the question said: "...when you want to shorten some > object initialization" > > Using ClassVariable is an alternative way to shorten object > initialization, reading a ClassVariable is almost the same performance > as reading a literal, so that looked like a good alternative to me. Both > the ClassVariable and the literal have the same issues (same object so > if you mutate it you have to deal with it). > > But yes, it's not a new literal. > > For new literals, you can extend the compiler or hard patch thing: > > MyClass>>foo > ^ #bar > > (MyClass>>#foo) literalAt: ((MyClass>>#foo) literals indexOf: #bar) put: > Set new. > > MyClass new foo > >>>> a Set () > > Obviously it depends what you mean by literal, the latter code uses the > literal bytecode instruction, which does not make the pushed object a > literal object... -- Esteban A. Maringolo