Skip to content
This repository was archived by the owner on Dec 7, 2024. It is now read-only.
This repository was archived by the owner on Dec 7, 2024. It is now read-only.

Can feature names be reframed as parameters? #9

@lukewagner

Description

@lukewagner

I liked the reframing of this proposal in today's CG call as conditional compilation/inclusion, as opposed to feature-detection. However, iiuc, conditional expressions still bottom out in a feature-name string, so there is still the essential question: how is the set of feature-names defined?

In particular, I think there is one hard question that has bad outcomes with either answer: are browsers allowed to include ad hoc (not in some formal standard) feature strings?

  • If "yes": this will lead to vendor-specific feature names which will, in the fullness of time, likely play out like CSS vendor prefixes which browsers all agreed was, in retrospect, not a good idea.
  • If "no": then the granularity of feature testing may end up being too low (e.g., it has already been the case several times that a feature is deployed/released incrementally), so this feature doesn't end up solving the problem it was created to solve.

What if instead:

  • feature names were recast as "parameter names", with no a priori defined meaning
  • it was up to the host (e.g., using WebAssembly.validate() and other ad hoc probing methods) to answer the atomic question: "is feature X, for my definition of X, supported in this host?", ultimately passing that bool as the value for a parameter name at compile-time.

With this style of design:

  • no wasm or other standard needs to bake in for all time a list of "features" which are ultimately cruft, once widely implemented
  • conditional inclusion wouldn't be limited to just wasm feature availability but also questions like:
    • is navigator.hardwareConcurrency > 1?
    • are COOP and COEP set?
    • is (non-wasm) Web API X impemented?

I'm not sure what the exact right API design is for this. One obvious idea is that WebAssembly.compile() (and other APIs that compile from bytecode to a Module) could take a (parameter,value) list, feeding those values into the conditions when compiling the module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions