c++,casting,language-lawyer,pointer-to-member,thunk
As per the comments -- this is actually a non-standard extension of MSVC -- GCC and CLang are both handling this correctly by default. Anyone else who sees this should use the /vmg switch on their compiler command line to disable the MSVC extension that allows for 'compacted' PMFs in...
You might be interested in the Promise.fromTry method. That method uses the Try idiom from scala.util, which is a useful structure that allows you to treat a try...catch statement more like a traditional constructs: Promise.fromTry { Try { someOtherFunction(intParam1, intParam2) } } If you wanted to right your own helper...
functional-programming,lazy-evaluation,thunk
If you have the choice, use lazy evaluation for expressions that may not be evaluated at all or may lead to programming errors under certain circumstances when evaluated. The classic case is implemented in most languages descending from C and is called "short circuit operators": if (i != 0 &&...
Use a promise for this (return a promise, not a thunk). Off the top of my head, so you may need to play around with it: function run(url, s) { return new Promise(function(resolve, reject) { var req = http.request(url, function(res) { res.pipe(s); res.on('end', function() { req.end(); }); }); req.on('error', function(err)...