Allen Wirfs-Brock wrote:
Another loose end.

With the addition of for-of, for-in reverts back to always iterating over the property keys of an object as it does not support the generalized iteration protocols. An implication of this is that using a de-structuring pattern as the iteration variable has very limited utility:

    for (let [c] in obj) print(c);  //print the first character of
    each of obj's enumerable property names

    for (const {length:len}  in obj) print(len);  print the length
    of each of obj's enumerable property names


Given this lack of utility, why should we allow de-structuring in this context?

These are not totally silly examples. I say when in doubt, let language regularity win.

We are also thereby future-friendly in case some evolution of property keys becomes even more structured. I know, unlikely, but again: regularity when in doubt.

Eliminating it arguably increases language complexity by introducing in a bit more grammar irregularity. On the other hand, eliminating useless functionality can be seen as as simplification.

Not useless, your own examples show use-cases.

I'm leaning towards banning destructing in for-in.

Too nannyish!

/be


_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to