[Prototype-core] Re: Function.EMPTY and Function.K
On Saturday 26 September 2009 04:04:22 kangax wrote: On Sep 24, 11:20 pm, Andrew Dupont goo...@andrewdupont.net wrote: Unless anyone has serious objections, or has a better idea, I'm going to add these as aliases of `Prototype.emptyFunction` and `Prototype.K`, respectively. They belong better there, since in theory the `Prototype` namespace is for internal stuff, not for stuff that has value to end-user developers. It sure makes more sense to have those on `Function`. I kind of hate that we're putting yet another (completely made-up) method on yet another built-in native, but it looks like there's not much that can be done about it at this point anyway. As far as naming, I would probably go with `Function.empty` and `Function.identity` (`Function.K` looks neat but it would then make sense to uppercase `EMPTY` too, and I like lowercase version more). Now that we're on this subject, we can also add so often useful `Function.false` (i.e. `function(){ return false; }`). I use it all the time for things like preventing events - `someElement.onselectstart = Prototype.falseFunction;`, etc. Is anyone else using something like that? I have Function.alwaysReturn( val ); So, I'd use Function.alwaysReturn( false ) in that case. Is good for anywhere a function is expected but you want to insert a value. Eg, Function.alwaysReturn( 4 ); Function.alwaysReturn = function ( val ){ return (function(){return val}); }; -- Jim my wiki ajaxification thing: http://wikizzle.org my blog: http://jimhigson.blogspot.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Ajax.Responders.register for onFailure event
Hello Prototypers, Any reason why the Ajax.Responders does not support the registration of handlers for onFailure event? cheers -- mona --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Ajax.Responders.register for onFailure event
i knew it, i had asked the same question before [10/29/08] so i'll stick to the same recommended patch at [http://prototype.lighthouseapp.com/projects/8886/tickets/334-onsuccessfailure-not-dispatched-to-ajaxresponders] while waiting for the anax revamp in v2 thanks and sorry for the double post. cheers -- mona On Mon, Sep 28, 2009 at 11:35 AM, Mona Remlawi mona.reml...@gmail.com wrote: Hello Prototypers, Any reason why the Ajax.Responders does not support the registration of handlers for onFailure event? cheers -- mona --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Function.EMPTY and Function.K
On Sep 28, 3:44 am, Jim Higson j...@wikizzle.org wrote: On Saturday 26 September 2009 04:04:22 kangax wrote: On Sep 24, 11:20 pm, Andrew Dupont goo...@andrewdupont.net wrote: Unless anyone has serious objections, or has a better idea, I'm going to add these as aliases of `Prototype.emptyFunction` and `Prototype.K`, respectively. They belong better there, since in theory the `Prototype` namespace is for internal stuff, not for stuff that has value to end-user developers. It sure makes more sense to have those on `Function`. I kind of hate that we're putting yet another (completely made-up) method on yet another built-in native, but it looks like there's not much that can be done about it at this point anyway. As far as naming, I would probably go with `Function.empty` and `Function.identity` (`Function.K` looks neat but it would then make sense to uppercase `EMPTY` too, and I like lowercase version more). Now that we're on this subject, we can also add so often useful `Function.false` (i.e. `function(){ return false; }`). I use it all the time for things like preventing events - `someElement.onselectstart = Prototype.falseFunction;`, etc. Is anyone else using something like that? I have Function.alwaysReturn( val ); So, I'd use Function.alwaysReturn( false ) in that case. Is good for anywhere a function is expected but you want to insert a value. Eg, Function.alwaysReturn( 4 ); Function.alwaysReturn = function ( val ){ return (function(){return val}); }; I remember seeing this in Dean's base2.js and Oliver Steele's functional.js under then name - K: function K(value){ return function() { return value; } } It's then easy to define other abstractions with this one function - Function.empty = K(); Function.false = K(false); Function.true = K(true); // etc. -- kangax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: True Hashes using objects as keys
On Sep 11, 4:39 pm, kangax kan...@gmail.com wrote: On Sep 11, 7:08 am, T.J. Crowder t...@crowdersoftware.com wrote: [...] @Jim: Yep, this is Java-esque but that doesn't *always* equal evil! Hardly ever! I'd say hashCode has a place. Let's step back and ask the question: What are the use cases for a hash keyed by non-string objects? Are they compelling? (I'm not saying they aren't, just saying that before running off on an idea, we need to ask the question.) I would actually like to hear about use cases too. Developing web apps for 3 years now I haven't ever needed to use hash with arbitrary keys. It doesn't mean such thing is not useful; I'm just failing to see how (and where) it can be applied in practice (especially in a context of web apps). For what it's worth, my use case for developing the jshashtable (mentioned elsewhere on this thread) was in a fairly involved WYSIWYG editor (around 15,000 lines of code): I wanted to associate objects within quite a complicated model. I started using it for caching the results of operations on certain model objects and have ended up using it several places where a simple object would do, just for the convenience of the API. I have never used it with DOM elements as keys for the very reasons mentioned in this thread to do with keeping references to DOM nodes hanging around, though you'd be ok if you made sure you called clear() on one of my hash tables once you're finished with it. Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Function.EMPTY and Function.K
Prototype's existing String.empty and Array.empty interfaces would imply that Function.empty return a boolean indicating perhaps that the function is empty. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---