Re: [nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-13 Thread Isaac Schlueter
Michael, As the person empowered to make definitive statements about the direction of Node, here's the answer: Wherever it makes sense (for some definition of "sense", of course), Node's file system api follows the Posix patterns. Stat, lstat, and fstat all return the same type of object. Of co

Re: [nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-13 Thread Nikita Pchelintsev
> > files.map(function(file){ > fs.stat(file,function(stats){ > if(stats.isFile()){ > fs.readFile(file, function(err, theFile){ > //dosomething > }) > } > }) > }) > I don't think this example is correct, the variable "file" in fs.readFile(file, function(err,

[nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread Patrick Mueller
On Wednesday, December 12, 2012 10:52:19 AM UTC-5, greelgorke wrote: > Well, DOM Event API defines the EventListener interface. you could do this: > document.body.addEventListener('click', > {foo:'foo',handleEvent:function(ev){console.log(this.foo)}}) > and this will print foo to your console, bu

[nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread greelgorke
Well, DOM Event API defines the EventListener interface. you could do this: document.body.addEventListener('click', {foo:'foo',handleEvent:function(ev){console.log(this.foo)}}) and this will print foo to your console, but thats, right. it's possible just to pass a function and most of devs do thi

Re: [nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread greelgorke
i meant not pure functionAL style, but pure functions: http://en.wikipedia.org/wiki/Pure_function the state of the art at the moment is to use closures, which often are not pure functions. they close over some values from the parent scope, that is not under control of the closure itself. the clo

[nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread Patrick Mueller
On Wednesday, December 12, 2012 4:36:29 AM UTC-5, Michael Hasenstein wrote: > ... > > So, can anyone enlighten me - and I MAY INDEED be simply incredibly stupid > not to see the point without help - why node.js could not just let me add > custom parameters for callbacks? Again: additional scope-

[nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread greelgorke
yes, thanks, for the hint. :) Am Mittwoch, 12. Dezember 2012 12:16:27 UTC+1 schrieb Ruben Tan: > > I think you meant "closure". clojure is a language running on JVM. > > On Wednesday, December 12, 2012 6:59:56 PM UTC+8, greelgorke wrote: >> >> why? its the simpliest and most common way, that's it.

Re: [nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread Richard Miller-Smith
I'm certainly no expert, but I expect the design choice was made to do it that way to make the C/C++ asynchronous calls within the node core to be simpler and easier. At present, to jump back into the callback the C++ side just needs a single function reference. If a list of arbitrary arguments are

RE: [nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread Chad Engler
2012 6:53 AM To: nodejs@googlegroups.com Subject: Re: [nodejs] Re: Why no additional parameters in (async. node.js API) callback functions? I know how I can do it (at least 3 different very ways came to my mind immediately), I said so ;-) - that was't my question (or point). I don't WANT

Re: [nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread Jonathan Dickinson
At least with my .bind() example one could argue that it makes the code harder to read (yes, I completely agree with you about closure hell; and they are way less understandable than what I am about to say): it has to do with expression of intent. To the untrained eye, what is going on here? fs

Re: [nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread Michael Hasenstein
I know how I can do it (at least 3 different very ways came to my mind immediately), I said so ;-) - that was't my question (or point). I don't WANT to have to write that, if I can help it. I would except the explanation that since node.js is very low-level burdening the API functions with an add

[nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread Jonathan Dickinson
You can do it with .bind(). I assume that the 1...n arguments of .bind() are often overlooked. var fs = require('fs'); function onStat(file, err, stat) { if (stat.isFile()) { //fs.readFile(...)... WHICH FILE console.log(file); // This file } } var files = [ "E:\\site

Re: [nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread Michael Hasenstein
CORRECTION, I take my last statement back, you DID add to the conversation and I am a bad reader. I had already considered the performance issue of having the API functions not just call the callback, but also having to handle OPTIONAL additional parameters, which in node.js might happen some mill

[nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread Ruben Tan
I think you meant "closure". clojure is a language running on JVM. On Wednesday, December 12, 2012 6:59:56 PM UTC+8, greelgorke wrote: > > why? its the simpliest and most common way, that's it. passing by custom > params has to be implemented in the async function itself, there is no > native su

Re: [nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread Michael Hasenstein
Sir, you did not understand my question :) However, I don't see how I could possibly be clearer - which definitely is MY shortcoming. So sorry. On Wed, Dec 12, 2012 at 11:59 AM, greelgorke wrote: > why? its the simpliest and most common way, that's it. passing by custom > params has to be impl

[nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread greelgorke
why? its the simpliest and most common way, that's it. passing by custom params has to be implemented in the async function itself, there is no native support in js nor node for this. and since use of clojures is very common in js world, mostly noone cares about it. but yes it may help to un-cl