On 11/18/07, Per Cederberg <[EMAIL PROTECTED]> wrote: > > #1. Is there a way to do "late" binding with MochiKit.Base.bind? I.e. > allowing function names to be resolved when the returned function is > called, rather than when bind() is called. See example below: > > obj = { > a: function() { return "a"; }, > } > var test = MochiKit.Base.bind("a", obj); > test() ==> "a" > obj.a = function() { return "b"; } > test() ==> "b" (currently MochiKit returns "a" here) > > It is easy enough to modify the MochiKit.Base.bind(), but it would of > course break semantic backwards compability a bit.
I gave it a shot and it definitely breaks backwards compatibility in a way that the tests fail. I won't be doing this, but you can do this with forwardCall. >>> obj = {a: function () { return "a"; }} [object Object] >>> test = bind(forwardCall("a"), obj) function () {...} >>> test() "a" >>> obj.a = function () { return "b"; } function () {...} >>> test() "b" > #3. With a few quick hacks to set class and function names on object > functions I've been able to implement JavaScript stack traces. And > combined with logging, this has proven extremely powerful for > debugging issues in the application. > > Is there something for stacktraces already in MochiKit? Would it be > welcomed as a patch? I've done things like this before, but not in MochiKit. I started caring a lot less about debugging tools since Firebug came out :) A patch would be good. -bob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~----------~----~----~----~------~----~------~--~---