CLIM mail archive

[Prev][Next][Index][Thread]

Mutabillity of Clim regions



    Date: Fri, 7 Jan 1994 03:26 EST
    From: berni@iml.fhg.de

    Hi there.

    I have a question concerning the (im)mutability of Clim regions.

    My application uses some gemoteric reasoning about certain objects.
    The CLIM region (prolygon) protocol fits very well to this problems, so I am
    thinking about two possiblities:

    A)  This objects have a region accessor, whose value is an instance of
	class standard-polygon. I use the region-functions on this instance
	or write some trampoline functions.
	However, the drawback is that for every change in the geometric properties
	(i.e. position, rotation, dimensions) I have to cons a new instance.
	Especially position changes occur quite often.

    B)  I make my objects subclasses of class standard-polygon and modify
	the  coordinate-related values each time there is a change in the
	geometric properties. (So position changes dont require consing)
	Thus I make it a mutable object.
	Will this lead to any problems (e.g., I could imagine that some
	implementations of bounding-rectangle for standard-pologon 
	cache their result in the polygon instance)

There were long bitter debates about whether designs (including regions,
colors) and transformations should be immutable or not.  The sort of
thing you mention was just one of the arguments that the supporters of
immutability brought up.  It turns out that CLIM does not do the exact
optimization you talk about, but CLIM does use EQ-ness of colors,
patterns, bounding rectangles (in some cases) and transformations to
serve as keys in a number of internal caches.  At least one possible
implementation of output recording could also be made more robust, and
probably more efficient, with immutable regions.

But the people who did not want immutable regions were thinking of
applications such as your own, although so far you are the first person
to ask about this.

    What approach should I take?

The approach you are taking is reasonable, but I would suggest that you
avoid using these new, mutable classes as arguments to CLIM drawing
functions.  Unless you are using DRAW-DESIGN, that shouldn't be a major
problem.  You can use the DRAW-xxx* functions, and I imagine that you
won't be using these designs as the :INK argument.  If you want to use
DRAW-DESIGN or want to use one of your regions as a :CLIPPING-REGION,
you might consider copying the object.

    Thanks - Stefan.
    --------------------------------------------------------------
    Stefan Bernemann                     Tel.: +49-231-9743-139
    FhG IML                              Fax:  +49-213-9743-234
    Joseph-von-Fraunhofer-Str. 2-4       email: berni@iml.fhg.de
    D44227 Dortmund



References:

Main Index | Thread Index