Registry
See original GitHub issueIn #19 and #20 some confusion arose around the purpose of the registry. Currently it has the following responsibilities, which may or may not be useful:
Store available specs for easier access
So you can do this:
define("string", p.string)
conform("string", "foo")
Instead of always having to do it like this:
const string = p.string
conform(string, "foo")
However the underlying question is probably how different modules share their specs or provide them to “userspace.” Should they define
all their things to store them in the registry? (I don’t think it’s possible with npm
as, if I recall correctly, you can end up with depdendency A using js.spec v1 and dependency B with js.spec v1.1, effectively using different registry instances) Also, they still would need to share they IDs to look up in the registry.
// module A
export const specA = Symbol("string")
define(specA, p.string)
// module B
import {specA} from 'a'
conform(specA, "foo")
So maybe overall it’s better to use regular es6 modules for transporting specs directly.
// module A
export const specA = p.string
// module B
import {specA} from 'a'
conform(specA, "foo")
Which would make the registry obsolete.
Name the specs
The one other reason why the registry exists is that, since you give a semantically useful ID to define
, it can auto-name the specs, which is super important for error messages. Generic error messages are not helpful, especially when you consider two syntactically equal specs that have different semantics. (It’s in the morning, I don’t have a good example ready.)
Here I would just make the name
part of a spec’s data, it’s cleaner anyways.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (8 by maintainers)
Top GitHub Comments
Using modules makes more sense in a JS context. It simplifies the design and also improves the understandability–I can directly inspect the imported spec, whereas in a registry it’s hard to see where it came from, or worse, who redefined it.
So to sum it up, we agreed on:
Correct me if I’m wrong.