Mantis - Squeak
Viewing Issue Advanced Details
6797 Compiler minor always 12-03-07 20:47 04-18-10 22:05
nicolas cellier  
closed 3.10  
none trunk  
0006797: Compiler reduce ScaledDecimal with different scales to a single literal
I encountered this while testing 0004378.
Compiler try and reduce number of literals using equality test.
Unfortunately, this breaks some ScaledDecimal test:

  self assert: 0.5s1 scale = 1.
  self assert: 0.5s2 scale = 2.

Each assertion would work individually, but would break together.
 Compiler-literal-M6797-nice-Test.1.cs [^] (1,270 bytes) 12-03-07 21:13
 Compiler-Literal-M6797-nice-Patch.1.cs [^] (725 bytes) 03-12-08 22:17
 NewCompiler-Literal-M6797-nice-Patch.1.cs [^] (958 bytes) 08-29-08 07:31
 Compiler-Literal-M6797-nice-Patch.2.cs [^] (1,812 bytes) 08-29-08 07:32

nicolas cellier   
12-03-07 21:14   
Beware, Test.1.cs does define a CompilerTest TestCase.
If you have already one in your image, just load the method.
nicolas cellier   
03-12-08 22:19   
"fix begin"
Installer mantis bug: 6797 fix:'Compiler-Literal-M6797-nice-Patch.1.cs'.
"fix test"
Installer mantis bug: 6797 fix:'Compiler-literal-M6797-nice-Test.1.cs'.
"fix end"

08-28-08 12:34   
in NewCompiler this problem is solved with #literalEqual:

  oneLiteral literalEqual: otherLiteral

and the literal objects decide equality for themselves (take Array for example). the compiler should not know anything about Array, ScaledDecimal and any other literal's equality.

the default implementation of #literalEqual: in Object takes class == into account, otherwise 'literal' would be = #literal, for example.
nicolas cellier   
08-29-08 07:31   
Hi Klaus,
Thank you for your contribution.
I totally agree, my first patch is a quick and dirty lightweight hack,
compared to the clean and extensible solution adopted in NewCompiler.
You are right to remind us the Smalltalk way.

Please find two new versions based on your proposition.
NewCompiler-Literal-M6797-nice-Patch.1.cs to patch only the NewCompiler
Compiler-Literal-M6797-nice-Patch.2.cs to patch both the (Old)Compiler and NewCompiler.

The only problem i foresee doing so, is that loading NewCompiler then unloading it might remove #literalEqual: and thus prevent (Old)Compiler to compile literals. But that's a small packaging problem.

08-29-08 15:55   
the new patches look good; I will inform the NewCompiler team (and Pharo team, for that matter) that there is something from you for them.

thanks nice
nicolas cellier   
08-29-08 19:38   
"fix begin"
Installer mantis bug: 6797 fix:'Compiler-Literal-M6797-nice-Patch.2.cs'.
"fix test"
Installer mantis bug: 6797 fix:'Compiler-literal-M6797-nice-Test.1.cs'.
"fix end"
nicolas cellier   
09-12-09 19:25   
Fixed in: [^] [^]