On Fri, Jun 27, 2014 at 11:58 AM, Esteban A. Maringolo <[email protected] > wrote:
> Because Smalltalk lacks a "switch/case" control flow structure? :) > and of course it has one that works just fine. Esteban A. Maringolo > > > 2014-06-27 15:42 GMT-03:00 Denis Kudriashov <[email protected]>: > > I always wondering how anybody can write such code with smalltalk > > > > > > 2014-06-26 0:43 GMT+04:00 stepharo <[email protected]>: > Steph, it begs for double-dispatching. So why shoot InfiniteForm instead of fixing the code/ It makes no sense to me. Double-dispatching is a pattern you know well. Apply it here. > > > >> because when I see code like that, it makes me sick! > >> I wonder also when we migrate to Athens if we will not rewrite all that > >> anyway. > >> > >> fillRectangle: aRectangle basicFillStyle: aFillStyle > >> "Fill the given rectangle with the given, non-composite, fill > style." > >> > >> | pattern | > >> > >> (aFillStyle isKindOf: InfiniteForm) ifTrue: [ > >> ^self infiniteFillRectangle: aRectangle fillStyle: aFillStyle > >> ]. > >> > >> (aFillStyle isSolidFill) > >> ifTrue:[^self fillRectangle: aRectangle color: aFillStyle > >> asColor]. > >> > >> "We have a very special case for filling with infinite forms" > >> (aFillStyle isBitmapFill and:[aFillStyle origin = (0@0)]) ifTrue:[ > >> pattern := aFillStyle form. > >> (aFillStyle direction = (pattern width @ 0) > >> and:[aFillStyle normal = (0@pattern height)]) ifTrue:[ > >> "Can use an InfiniteForm" > >> ^self fillRectangle: aRectangle color: (InfiniteForm > with: > >> pattern)]. > >> ]. > >> "Use a BalloonCanvas instead" > >> self balloonFillRectangle: aRectangle fillStyle: aFillStyle. > >> > > > > -- best, Eliot
