Another newbie question
Alex Martelli
aleax at mail.comcast.net
Sat Dec 10 21:11:20 EST 2005
Bernhard Herzog <bh at intevation.de> wrote:
...
> > and y, obviously. However, a framework for 2D geometry entirely based
> > on immutable-instance classes would probably be unwieldy
>
> Skencil's basic objects for 2d geometry, points and transformations, are
> immutable. It works fine. Immutable object have the great advantage of
> making reasoning about the code much easier as the can't change behind
> your back.
Yes, that's important -- on the flip side, you may, in some cases, wish
you had mutable primitives for performance reasons (I keep daydreaming
about adding mutable-number classes to gmpy...;-)
> More complex objects such as poly bezier curves are mutable in Skencil,
> and I'm not sure anymore that that was a good design decision. In most
> cases where bezier curve is modified the best approach is to simply
> build a new bezier curve anyway. Sort of like list-comprehensions make
> it easier to "modify" a list by creating a new list based on the old
> one.
True, not for nothing were list comprehensions copied from the
functional language Haskell -- they work wonderfully well with immutable
data, unsurprisingly;-). However, what if (e.g.) one anchor point
within the spline is being moved interactively? I have no hard data,
just a suspicion that modifying the spline may be more efficient than
generating and tossing away a lot of immutable splines...
Alex
More information about the Python-list
mailing list