On 07/29/2016 12:26 PM, George Neuner wrote:
> I don't see any obvious utility in being allowed to create a zero
> sized bitmap.  Likewise a widget or a canvas.

It is useful when writing code that handles images generically. For
example, and this is a real example where the zero-size-bitmap error bit
me the other day, when rendering `2htdp/image`s to `bitmap%`s.

Here's the code I have now:

     (define w (max 1 (image:image-width i)))
     (define h (max 1 (image:image-height i)))

where previously it was

     (define w (image:image-width i))
     (define h (image:image-height i))

I consider the `(max 1 ...)` to have made my code less elegant and more
brittle.

*Negative* dimensions don't make sense. But zero dimensions do. (I feel
like I want to waffle about closure properties...)

> IMO a zero dimension should be an error.  If you don't know how big
> the bitmap should be, don't create it until you do.

In the case I was facing, rendering `2htdp/image`'s `empty-image` to a
`bitmap%`, I knew exactly how big it should be: 0x0. I think supporting
0x0 bitmaps makes good sense and helps avoid brittleness and inelegance.

Tony

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to