[whatwg] Canvas 2d methods

On Sun, 2 Jul 2006, Andrew Fedoniouk wrote:
> > On Sat, 1 Jul 2006, Andrew Fedoniouk wrote:
> > > 
> > > In prototype based languages it is almost impossible to implement 
> > > 'with' effectively in the given notation.
> > > 
> > > ctx.moveTo(0,0).lineTo(10,10);
> > > 
> > > is more effective. In some circumstances - in times.
> > 
> > Why is it more effective for JS?
> 
> foo.bar()
> 
> requires lookup only in foo and its proto chain. And

...for "bar". It still requires a complete lookup for "foo" in all the 
parts of the scope chain.

> with(foo) {  bar() }
> 
> requires lookup in 'with stack', current function namespace and stack of 
> global namespaces.

...just as you normally would for "foo" anyway.


> When foo contains bar and you are doing lookup for read these cases are 
> almost identical but if you have something like
> 
> foo.bar = 1;
> 
> and
> 
> with( foo ) { bar = 1; }
> 
> and foo does not contain that bar you need to scan whole namespace chain 
> (with case). In short 'with' creates additional level of ambiguity.

This is only the case where you don't know what "foo" will contain. In 
this case what "foo" contains is very explicitly defined.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Sunday, 2 July 2006 12:59:07 UTC