[squeak-dev] Strange Behavior Variance between Form and Cursor

Bob Arning arning315 at comcast.net
Sat Aug 18 22:07:48 UTC 2012


The comment in Cursor class extent:fromArray:offset: tells it all:

"NOTE: This has been kluged to take an array of 16-bit constants,
     and shift them over so they are left-justified in a 32-bit bitmap"

When any Form needs less than 32 bits per row (or less tham 32 bits from 
the last word in a row), it uses the most significant bits. Cursor was 
modified to fill the upper 16 bits of each word in the bitmap with the 
required data without requiring the user to shift as you did in your 
final example. Without that, you would need to do something like:

(Cursor
     extent: 16 at 16
     depth: 1
     fromArray: #( 4294901760 134152192 2029977600 2134835200 2145320960 
2146369536 2146893824 2146893824 2147155968 2147155968 2147155968 
2147287040 2147287040 2147287040 2147287040 65536)
     offset: 0 at 0)

(this being a storeString of your final Form example). This takes more 
space textually, requires some LargeIntegers and is harder to parse by 
eyeball (I can tell the Cursor start with a black row from 65535, but 
4294901760 leave me reaching for a workspace).

Cheers,
Bob

On 8/18/12 4:41 PM, JohnReed Maffeo wrote:
> Cursor is a subclass of Form but their extent:fromArray:offset methods produce significantly different results.
>
> In a workspace, I inspect two instances
>
> Cursor extent: 16 at 16 fromArray: #(65535 2047 30975 32575 32735 32751 32759 32759 32763 32763 32763 32765 32765 32765 32765 1) offset: 0 at 0
>
> Form extent: 16 at 16 fromArray: #(65535 2047 30975 32575 32735 32751 32759 32759 32763 32763 32763 32765 32765 32765 32765 1) offset: 0 at 0
>
> In the inspector browser in each, I do "self displayOn: Display"
>
> The cursor instance displays an Arc icon in the upper left hand corner of the Display.
> The cursor instance displays a white box icon in the upper left hand corner of the Display.
>
> The difference appears to be the fact the the Cursor method applies a bitShift: 16 to the elements of the input array.
>
> I have observed these results in the Squeak4.2-10966 and the minimal-MVC (nee Squeak3.8.18beta3u ?).
>
> It seems to violate the principle of least astonishment. Is it a bug, a feature or an interesting artifact?
>
> This was discovered while I was doing some work trying to port and old Smalltalk-80 graphics application as part of my self study process.
>
> I can get the results I am looking for by doing this:
>
> Form extent: 16 at 16
>   fromArray:  (#(65535 2047 30975 32575 32735 32751 32759 32759 32763 32763 32763 32765 32765 32765 32765 1)
> collect: [ :each | each bitShift: 16]) offset: 0 at 0
>
> Regards,
>
> John-Reed
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20120818/2d2cd07d/attachment.htm


More information about the Squeak-dev mailing list