2 ms·
> Lets drop async/await and write our own interpreters. Let's "codify" patterns instead of having everybody roll his own implementation thus make codebases mo
by spriggan3 11y ago
> Lets drop async/await and write our own interpreters.
Let's "codify" patterns instead of having everybody roll his own implementation thus make codebases more compatible.
All criticisms made in the article are 100% valid, however the former principle trumps every other one.
I don't want having to import yet another micro-module just to write something that should be trivial to do in plain javascript.
As for try/catch, some languages support pattern matching, why not Javascript?
- carussell 11y agoSome form of catch guards have been implemented in Firefox for over a decade, so if you were running SpiderNode, you could use them right now. try { (17).toString(42); } catch (ex if ex instanceof RangeError) { console.log("caught"); } catch (ex) { console.log("handling something else"); } The if's clause has standard standard conditional semantics, so you can use any expression there; you aren't limited to selecting on the exception's prototype: try { throw new Error("whatever"); } catch (ex if ex.message == "whatever") { console.log("caught"); }
- tracker1 11y agoWell, it's entirely possible to submit that as a stage-0, then it could get in babel and be used sooner than later.