On Sun, Aug 19, 2012 at 3:24 AM, Jeffrey Zhao <[email protected]> wrote:
> 1) I don’t know there’s a transform API in streamline, sorry. If
> there’s one then using a eval() can do exactly the samething with Wind.js
>
For example using callbacks:
-----
var transform = require('streamline/lib/callbacks/transform');
function x(_) {
console.log('a 1');
setTimeout(_, 1000);
console.log('a 2');
setTimeout(_, 1000);
console.log('a 3');
setTimeout(_, 1000);
return 'go';
};
eval( transform.transform('' + x, {} ) );
x( function( err, ret ) {
if (err) { throw err; }
console.log('return: ' + ret);
});
-------
> 2) What do you mean callback is called synchronously? If you don’t have
> any async operations in the method body, Wind.js ould generate a async task
> which would be executed synchronously.
>
Sometimes callback implementations call the callback before they return,
for example when they got the answer cached. streamline uses the clever
trampoling approach to optimize for that. So in case you got an API that
caches, streamline generates more effective code than a normal human coder
would (I know there are some people like Tim who are really so good to do
it themselves, but for the normal being this is a bon)
And yes, with the filter support, we can generate much more compact and
> readable code. Considering the case of Node.js, I think we can easily add
> the support in Wind.js as an option.
>
For one see 2) if you leave away the trampoline it gets compacter, but is
less effective. Also I'd like to see a side-by-side comparison of some
examples to objectively see what can be improved. I for one don't look at
the generated code at all, since it got 1:1 line any error messages make
sense in themselves. Streamline also generates stacktraces that match the
original source, which is also quite nice.
--
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