Hi,

This is interesting. You probably had at look at taskjs.org.  Generators 
are kinds of structured fibers that, yes, can be "abused" to provide some 
form of threading. How "unobstrusive" this can be remains to be fully 
explored, as you do, in good company (see also streamline implementation 
using generators, an interesting exploration too).

Your approach reminds me about the "await" construct in C#, the"yield" in 
your example really means "await".

After much thinking, I came to the conclusion that this flow control issue 
is not such a big deal, solutions like "promise/a" demonstrates that async 
activities can be orchestrated in a readable way without threads. Besides, 
early implementations of generators are apparently rather slow (fibers are 
fast, non standard... and controversial).

I am conducting an experiment about a similar control flow problem, here is 
one result:

  var Parole = require('l8/lib/whisper'), fs = require( 'fs' );

 

  var read = Parole(); fs.readFile( __filename, read );

  read.on( function( err, data ){ console.log( data.toString( 'utf8' ); } );

  // or: read.then( function( data ){ console.log( data.toString( 'utf8' ); 
} );


This is more concise, does not have the array destructuring issue, runs 
today everywhere and is readable once you understand that a Parole() is an 
extended Function suitable as a node.js callback.

See https://github.com/JeanHuguesRobert/l8/wiki/ParoleReference. You may be 
surprised by the P.generator() easy way of defining an async generator 
using today's javascript.

Yours,

    Jean Hugues




 

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to