- From: Stefan Gössner <stefan@goessner.net>
- Date: Tue, 04 Jul 2006 01:57:21 +0200
L. David Baron wrote: >On Sunday 2006-07-02 22:47 +0200, Stefan G?ssner wrote: > > >>hmm ... >> >>ctx.scale(2,1) >> .rotate(Math.PI/4) >> .translate(4,-6); >> >>illustrates a sequence of manipulations semantically very well, doesn't it? >> >> > >In my opinion, this pattern generally makes sense semantically when used >on immutable objects (e.g., strings in JavaScript). > >I don't think this pattern makes sense for mutable objects. It just >suggests immutability. And making the canvas context objects immutable >doesn't really make sense without much more significant changes. > >-David > > > I don't understand the mutable/immutable argument. If I had a mutable Point object var Point = { x:0,y:0,z:0, setX: function(x) {..}, setY: function(y) {..}, setZ: function(z) {..} }; why should this pattern Point.setX(1); Point.setY(2); Point.setZ(3); make semantically more sense than Point.setX(1) .setY(2) .setZ(3); The object's state is altered always in the same *intended* order. And the latter doesn't suggest more immutability than the former in my opinion. The same mechanism applies to the current transformation matrix, which is part of the drawing state of the canvas' context object. -- Stefan G?ssner http://goessner.net
Received on Monday, 3 July 2006 16:57:21 UTC