Why does this fail? 
Author Message
 Why does this fail?

If I execute the following code I'll get a wallback complaining about true
(false) not understanding #>= although this message isn't sent!!

Just execute the following:

1 to: 10 do: [ :n1 |
    1 to: 10 do: [ :n2 |
        n1 = n2 ifTrue: ["Error!"]
    ]
].

Is this an obvious error or did I miss somethig?

Udo



Sat, 24 Apr 2004 04:16:47 GMT  
 Why does this fail?
Udo,

Quote:
> Is this an obvious error or did I miss somethig?

It's a problem that's been around for some time and is to do with the way
the Dolphin compiler optimises some code sequences.

From the archive (Blair in 1999)

=~=~=~=~=

Its a compiler bug that occurs when empty #ifTrue:[ifFalse:] statements
occur inside an optimized to:do: loop. Inspecting the bytecodes shows that
the compiler has optimized away the redundant conditional, but failed to pop
the result of the condition expression. It seems that this only happens when
the compiler thinks it can remove the #ifTrue:[ifFalse:].

=~=~=~=~=

Just make sure that there is always something in the block -

1 to: 10 do: [ :n1 |
    1 to: 10 do: [ :n2 |
        n1 = n2 ifTrue: [1 + 1]]].

Bit of a kludge but it doesn't happen very often.

Ian



Sat, 24 Apr 2004 04:43:08 GMT  
 Why does this fail?
Ian,

thanks for the quick reply. This explains alot.

So the only way to discover this is to do "incremental" developing ;-)

Udo



Quote:
> Udo,

> > Is this an obvious error or did I miss somethig?

> It's a problem that's been around for some time and is to do with the way
> the Dolphin compiler optimises some code sequences.

> From the archive (Blair in 1999)

> =~=~=~=~=

> Its a compiler bug that occurs when empty #ifTrue:[ifFalse:] statements
> occur inside an optimized to:do: loop. Inspecting the bytecodes shows that
> the compiler has optimized away the redundant conditional, but failed to
pop
> the result of the condition expression. It seems that this only happens
when
> the compiler thinks it can remove the #ifTrue:[ifFalse:].

> =~=~=~=~=

> Just make sure that there is always something in the block -

> 1 to: 10 do: [ :n1 |
>     1 to: 10 do: [ :n2 |
>         n1 = n2 ifTrue: [1 + 1]]].

> Bit of a kludge but it doesn't happen very often.

> Ian



Sat, 24 Apr 2004 04:46:49 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. nmake for windows doesn't have DONE or FAILED

2. PyImport_Import() fails - what am I doing wrong here?

3. why why why oh why why baby

4. Why is SetKey doing something different?

5. Why Forth is not doing so well

6. functions -- what is Verilog doing here and why?

7. Why was this done?

8. Why is the DOE selling AdaSage ????

9. Why are most HPC done in Fortran?

10. Why are most HPC done

11. Why are most HPC done

12. pep 308: why doing (almost) nothing suffices

 

 
Powered by phpBB® Forum Software