Begin forwarded message:

From: nicolas cellier <[EMAIL PROTECTED]>
Date: June 13, 2008 3:28:25 AM CEDT
To: [EMAIL PROTECTED]
Subject: [squeak-dev] to:do: optimization is wrong when the block modifies the limit Reply-To: The general-purpose Squeak developers list <[EMAIL PROTECTED] >

While browsing #to:do: optimization implementation i noticed this:

| n |
n := 2.
1 to: n do: [:i | (n := n+1)>10 ifTrue: [self halt: 'Should I get here?']].
^n

When you think in term of message send, well NO, YOU SHOULD NOT GET HERE.

Optimization is such a subtle thing that:

| n |
1 to: (n := 2) do: [:i | n := n+1. n>10 ifTrue: [self halt: 'You won''t get there']].
^n

Ha Ha, it's really fun!
Of course, if one corrects this bug, there is a pending Decompiler issue:

testDecompileToDoWithMovingLimit
        | n i |
        n := 4.
        i := 1.
        [i <= n] whileTrue: [
                n := n - 1.
                i := i + 1].

would decompile into:
        | n |
        n := 4.
        1
                to: n
                do: [:i | n := n - 1]

This is worth a http://bugs.squeak.org/view.php?id=7093
Ah i wonder what would a NewCompiler do to to:do:

Nicolas





_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to