domenic / proposal-blocks

Former home of a proposal for a new syntactic construct for serializable blocks of JavaScript code
215 stars 5 forks source link

Statically-analysable imports #16

Open YarnSphere opened 6 years ago

YarnSphere commented 6 years ago

Mostly out of curiosity, what are the difficulties behind allowing statically-analysable import statements inside blöcks?

The way I see it, the engine can "register" such imports in the blöck literal at compile-time and feed it what was imported at reification-time (even if with import()-like semantics). I'm probably being naïve here, so I'd like to hear what are the biggest issues with such an approach.

domenic commented 6 years ago

The main issue is that it's supremely useful (as shown in the examples) to be able to use await. And there's currently no syntax goal that allows both await and import statements. So I picked the more useful one.

If top-level await happens, then there might be a path forward. Although, then people who thing "this should just be a function" (like #2) would start pushing back.