Hah, most people hate that about Perl. I always did. I much prefer having the implicit "this".
On Tue, May 29, 2012 at 9:07 AM, Felipe Gasper <[email protected]>wrote: > (Slightly OT for this list, but...) > > Just curious, was there, is there ongoing, a discussion of the prudence of > having a context object in the first place? > > IMO, Perl does this the right way: the namespace/$this is just the first > argument that the function receives; i.e., $obj->func('foo') will receive > args of ( $obj, 'foo' ). > > -FG > > > On 29.5.12 5:56 AM, Oliver Leics wrote: > >> For me >> >> setTimeout(function() { console.log(x) }, 5000) >> >> is cleaner than >> >> setTimeout(console.log.bind(**console, x), 5000) >> >> I used .bind() a lot to get rid of scope-problems for once and all >> times. But then the code became, well, a mess: Everything I saw was >> calls to .bind() ;-) Way too much noise. And it did not really solve >> every scope-problem for once and all times. >> >> Now I use .bind() when it is really necessary. >> >> >> >> On Tue, May 29, 2012 at 12:27 PM, Mariusz Nowak<[email protected]> >> wrote: >> >>> Use what works for you, and don't bother with premature optimization. >>> >>> By the way it's not greatest bind use case, I wouldn't use bind here. In >>> some older versions of node (v0.6.3 ?) , setTimeout passes one argument >>> to >>> the callback, and in your example it will be logged as well. >>> >>> >>> On Tuesday, May 29, 2012 2:52:46 AM UTC+2, phidelta wrote: >>> >>>> >>>> Hi all, >>>> >>>> I have recently come to use .bind a lot, because it makes for very >>>> clean code. >>>> >>>> So rather than doing >>>> >>>> <code> >>>> var x; // this has some value that comes from prior code >>>> setTimeout(function() { console.log(x) }, 5000); >>>> </code> >>>> >>>> I am now often doing >>>> >>>> <code> >>>> var x; >>>> setTimeout(console.log.bind(**console, x), 5000); >>>> </code> >>>> >>>> The question I have is: what is more performant? Is there any reason >>>> to avoid .bind()? >>>> >>>> Regards, Phil >>>> >>> >>> -- >>> Job Board: http://jobs.nodejs.org/ >>> Posting guidelines: >>> https://github.com/joyent/**node/wiki/Mailing-List-**Posting-Guidelines<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines> >>> You received this message because you are subscribed to the Google >>> Groups "nodejs" group. >>> To post to this group, send email to [email protected] >>> To unsubscribe from this group, send email to >>> nodejs+unsubscribe@**googlegroups.com<nodejs%[email protected]> >>> For more options, visit this group at >>> http://groups.google.com/**group/nodejs?hl=en?hl=en<http://groups.google.com/group/nodejs?hl=en?hl=en> >>> >> >> >> >> > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: https://github.com/joyent/**node/wiki/Mailing-List-** > Posting-Guidelines<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines> > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > nodejs+unsubscribe@**googlegroups.com<nodejs%[email protected]> > For more options, visit this group at > http://groups.google.com/**group/nodejs?hl=en?hl=en<http://groups.google.com/group/nodejs?hl=en?hl=en> > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" 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/nodejs?hl=en?hl=en
