[whatwg] Canvas 2d methods
sh at kobjects.org
Sun Jul 2 15:21:37 PDT 2006
I would like to second the request for returning the context in drawing
methods that currently return null.
I think the following example illustrates why "with" is considered harmful:
var lineWidth = 10;
var lineHeight = 20;
fillRect(0, 0, lineWidth, lineHeight);
Andrew Fedoniouk wrote:
> ----- Original Message ----- From: "Ian Hickson" <ian at hixie.ch>
> To: "Andrew Fedoniouk" <news at terrainformatica.com>
> Cc: <vladimir at pobox.com>; "Benjamin Joffe" <canvasgame at gmail.com>;
> <whatwg at whatwg.org>
> Sent: Sunday, July 02, 2006 2:18 PM
> Subject: Re: [whatwg] Canvas 2d methods
>> On Sun, 2 Jul 2006, Andrew Fedoniouk wrote:
>>> 1) if it is declared as
>>> var foo = something; in current frame then
>>> then execution is quite efficient.
>>> still requires scan of the whole universe in the worst case.
>> But this isn't the worst case! It's the best case -- you know exactly
>> a 2D context's members are.
>>> Consider this:
>>> bar( some_var_name );
>>> runtime will scan full chain of ctx for some_var_name. What for?
>> It will scan *exactly* the same places as it would have if you didn't
>> the "with", plus the context itself.
> And that ctx is pretty heavy thing.
> Again, "with" was considered harmful - that was the inital idea of
>> Anyway, this is all a straw man -- this isn't the reason that the spec
>> doesn't allow this. It doesn't allow this because Safari didn't do it
>> way in the first place, and changing it would likely introduce bugs
>> still not helping authors for some time anyway).
> As far as I can see return value is not defined at all in:
> So the proposal is just to define them as returning 'this' instead of
> Andrew Fedoniouk.
More information about the whatwg