I wish there was a way to write const [A, B] = fn(), and inside fn() write return [A, B], and have @flowtype fail on “name” mismatches.
-
Show this thread
-
Or, put it another way, I wish there was a way to “pack” named properties into a type checked tuple that would be compiled to an array.
3 replies 1 retweet 15 likesShow this thread -
Replying to @dan_abramov @flowtype
This is exactly what happens when you compile
@reasonml to JavaScript. In fact the code on left is almost valid ES6 even.pic.twitter.com/xnjhjy1V8A
3 replies 13 retweets 75 likes -
Replying to @jordwalke @dan_abramov and
JIT friendly(er) too (or at least, the worst case JIT thrash I’ve seen with regular JS objects would not be possible)
1 reply 0 retweets 4 likes -
Replying to @jordwalke @dan_abramov and
I’d really like TC39 to consider a Struct() construct which is like an Array but never dynamic, has no proto, avoiding all dynamic checks.
4 replies 8 retweets 53 likes -
Replying to @jordwalke @dan_abramov and
The array representation of records/variants is great for predictability but we have even more static knowledge than is being capitalized on
1 reply 0 retweets 5 likes -
Replying to @jordwalke @dan_abramov and
Do you have an example of static data that isn't being used right now, and why?
1 reply 0 retweets 0 likes -
Replying to @GaryBorton @dan_abramov and
If you make a pointXY and compile it with ocamlopt, it's two x86 assembly instructions to access the x field. That's because the exact offsets in the allocation are known at compile time. Yet here we are stuck using JavaScript Arrays which go through a huge ceremony to access.
1 reply 1 retweet 0 likes -
Replying to @jordwalke @GaryBorton and
It will never be two assembly instructions in the browser because we need some safety checks, and sandboxing, but I suspect it can be further reduced from the current state. And we don't want to have to wait for a JIT to (hopefully) figure it out.
1 reply 0 retweets 0 likes -
Replying to @jordwalke @GaryBorton and
Because we already know the answer at compile time.
1 reply 0 retweets 0 likes
So you want Typed Objects?
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.