[Cuis-dev] [DEFECT] De-compling code uses #storeOn:

Juan Vuletich JuanVuletich at zoho.com
Wed Dec 15 05:17:04 PST 2021


On 12/10/2021 12:22 PM, Gerald Klix via Cuis-dev wrote:
> Hi all, Hi Juan,
>
> There is a defect in de-compiling code.
> After de-compiling the resulting method node
> is pretty printed. Constants defined with
> a back-tick are "printed" by using #storeOn:,
> which -- IHMO -- is dangerous as this
> example method source proves:
>
> --- snip ---
> boom
>     "Decompile me ..."
>
>     ^ `Smalltalk asDictionary` size
> --- snap ---
>
> The problem got much worse, when #linesOfCode
> was based on #decompiledString.
> Just selecting a package containing such a
> method in the package browser
> will cause the VM or the OS to run out of memory.
>
> I think we need something like #printDecompiledOn:
> which should do something sensible,
> like sending #store: but limiting
> the output size.
>
>
> Best Regards,
>
> Gerald

I see. I'm not too worried about that. I think backtick literals should 
only be used for very simple things that don't have a literal specific 
syntax (like for example, points, fractions, complex numbers). And they 
should produce the same object structure each time the method is 
compiled (and the expression is evaluated). The result should also be 
the same if the backticks were removed and the expression was evaluated 
every time.

More complex things like this, that could give very different results 
each time the expression is evaluated, should better live in a class 
variable (or a class instance variable), and set up in a class #initialize.

Perhaps a warning "Dude, don't use backticks for this" would be nice. 
Anyway, anybody playing with this kind of stuff will quickly learn all this.

Cheers,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.researchgate.net/profile/Juan-Vuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich



More information about the Cuis-dev mailing list