On Tue, Apr 29, 2014 at 7:47 PM, David Herman <[email protected]> wrote:
> Promised you a reply to this one, sorry -- I'm not comfortable with this
> restriction. It violates my Schemer's intuition [1]. In particular it
> creates a number of refactoring hazards: (1) add some try/finally
>
[...]
> [1] "Programming languages should be designed not by piling feature on top
> of feature, but by removing the weaknesses and restrictions that make
> additional features appear necessary."
>
In support of your intuition, here is how you'd implement Domenic's `using`
construct (or `for-using`) using the improved `for-of` (pardon the
mostly-ES5 syntax):
```js
var using = function*(o) {
try {
yield o;
} finally { o.close(); }
};
for (var file of using(open("filename"))) {
process(file.read()); // or whatever
}
```
- All three of .next, .throw, and .return should take an optional argument.
Calling `.throw()` with no arguments is surprising, but the result
(presumably throwing `undefined`) is consistent with the rest of the
language. I like the orthogonality of your proposal.
--scott
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss