Incongruent hash

Tim Olson tim at jumpnet.com
Thu Feb 12 16:03:42 UTC 1998


Ian wrote:

>Now, I'm supposing it's because to:do: is inlined, and 3 at 6+1=4 at 7. Is
>it at all possible to make a sensible to:do: method for Points?  The
>current one is just weird, and it would be better to just signal an
>error, I think.  Is the to:do: inlining impossible to get around?

Correct.  The method comment in Number>>to:do: says:

	"Normally compiled in-line, and therefore not overridable."

The inlining test for to:do: in the compiler only tests that the last 
argument is a literal block with one parameter, and that the increment, 
if any, is a constant number.

So you *could* prevent inlining and use your own Point>>to:by:do: method 
by specifying a by: argument that itself is a point, e.g.:

(1 at 1) to: (2 at 3) by: (1 at 1) do: [:pt | ....]

where Point>>to:by:do is something like:

to: stopPoint by: stepPoint do: aBlock

     self x to: stopPoint x by: stepPoint x do:
          [:x |
          self y to: stopPoint y by: stepPoint y do:
               [:y |
               aBlock value: x at y]].


However, I think it wouldn't be wise to do so, as it is relying upon an 
artifact of the current compiler's inlining tests, and is doing something 
that the comment in Number>>to:do: says shouldn't be done.



     -- tim





More information about the Squeak-dev mailing list