by cribbles · 2y ago · 0 comments
[1] https://engineering.fb.com/2010/02/09/developer-tools/xhp-a-...
But maybe we can revive the general idea with a modern take: https://github.com/WICG/webcomponents/issues/1069
Isn't this what we have in TFA?
But even considering the single implementation problem, it also was just not a good language model, nor was it well specified or defined and it brought with it a pile of weird baggage and complexity.
Then because it was The Future there was no real thought into proper interop with JS (it was essentially a completely independent spec so adopted general syntax but specified in a way that meant JS could not simply adopt that syntax).
Firefox never shipped the optional E4X DOM APIs. I wrote a polyfill for them at the time.[1]
VanillaJSX seems to suffer from the same problem though.
But there was no real progress after years of them pushing this syntax, but failing to actually define a type system that was coherent, or a model that would allow it.
As a result I proposed `for (of)` largely to prevent sane enumeration from being blocked on the intransigence of two people.
It's also worth noting that for(:) enumeration would not even preclude their syntax - it's certainly not grammatically ambiguous - and most real world code in languages that support enumeration directly and support inference doesn't explicitly specify the types , so the ugliness of `for(let a:type:expression)` would have be rare anyway.
shrug
Given that ECMA literally killed E4X a few years later the blanket ban on "for each" or "foreach" (because it would be "confusing" in E4X) is arguably worth than for(:), but again shrug
Typescript and similar can do it because they don't have to specify the type system, and can't change it in meaningful ways over time. Things in the language standard cannot be easily changed, if they can be changed at all.
It's clearly not strictly necessary though. Python has shown that.
I mean I agree it is pretty mad to just say "you can write types but they mean whatever" but surprisingly in practice it seems to work ok.