[webkit-dev] Adding LenientThis to WebKitIDL

Alec Flett alecflett at chromium.org
Wed Apr 10 16:56:01 PDT 2013


this is kind of what 'bind' is for, no?

it's a little wordy, but you can just pass:

console.log.bind(console)

instead of the closure.

its been around quite a while:
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind

personally as a web dev, it would frustrate me if console.log (or any other
api) behaved differently in webkit than in other engine.

Alec


On Wed, Apr 10, 2013 at 3:02 PM, Victor Costan <costan at gmail.com> wrote:

> Dear WebKit devs,
>
>
> I would like to make console.log and related functions work without
> requiring that "this" is set to the console object. This would make
> debugging from Web Inspector easier, because console.log could be
> passed directly to functions that require a callback, instead of
> having to pass function(arg) { console.log(arg); }
>
> In order to make this happen, I need a static method that shows up on
> the console object (or its prototype). The closest thing I could find
> in WebIDL is the [LenientThis] attribute. In WebIDL it's only intended
> for attributes, but I think it would be very useful for methods.
>
> If it makes a difference, Firefox supports using console.log without
> "this" being the console object, and this feature has been requested
> on the Chromium bug tracker, so it is useful to people other than
> myself.
>
>
> Before I embark on a quest to learn Perl so I can change the code
> generator, I would like to check if this is worthwhile. Would a patch
> along these lines be considered for WebKit? Is there another
> established pattern for achieving my goal? (e.g. some form of const
> attribute that returns a function?)
>
> Thank you very much for your help,
>     Victor
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20130410/b3381ab0/attachment.html>


More information about the webkit-dev mailing list