my bad, just noticed you do offer your own wrapper in the blog post cited.
There ya go.

.bind(this) is still not ugly

-1 if you were in any suggesting this get rolled into core.

+1 for you continuing to write wrappers when you want to extend/morph the
API.


On 2/7/08, Ryan Gahl <[EMAIL PROTECTED]> wrote:
>
> Completely disagree. First of all, you don't need the parentheses in your
> first example. You can simply do stuff like "function() {...}.bind(this)".
> Secondly, in your conclusion you are assuming that you will always _need_ to
> correct scope, when in fact you only need to do this if you want to use the
> keyword "this" within the iterator. There are many times when you would not
> be correcting scope at all, so then are you suggesting that we pass in null
> as the first param?
>
> Thirdly, and most importantly... just create a wrapper if you want this
> syntax... and get used to creating wrappers where you want/need a new API.
>
> //cache old method for calling within the override
> Array.prototype._oldEach = Array.prototype.each;
> Array.prototype.each = function(scope, iterator) {
> if (scope)
> iterator = iterator.bind(scope);
> return this._oldEach(iterator);
> };
>
> .bind(this) is not ugly by the way. It's a very elegant solution, and IMHO
> you'd be better served just getting used to it as you will see it in any
> prototype user's work, should you ever be part of a bigger team.
>
> On 2/7/08, sambo99 <[EMAIL PROTECTED]> wrote:
> >
> >
> > I blogged about this issue here:
> >
> >
> > http://www.samsaffron.com/archive/2008/02/09/A+cleaner+way+to+iterate+through+Enumerable+lists+in+Prototype
> >
> > I think iterators look nicer when you have the scope as the first
> > param.
> >
> >
> > > >
> >
>
>
> --
> Ryan Gahl
> Manager, Senior Software Engineer
> Nth Penguin, LLC
> http://www.nthpenguin.com
> --
> WebWidgetry.com / MashupStudio.com
> Future Home of the World's First Complete Web Platform
> --
> Inquire: 1-920-574-2218
> Blog: http://www.someElement.com
> LinkedIn Profile: http://www.linkedin.com/in/ryangahl
>



-- 
Ryan Gahl
Manager, Senior Software Engineer
Nth Penguin, LLC
http://www.nthpenguin.com
--
WebWidgetry.com / MashupStudio.com
Future Home of the World's First Complete Web Platform
--
Inquire: 1-920-574-2218
Blog: http://www.someElement.com
LinkedIn Profile: http://www.linkedin.com/in/ryangahl

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to