-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No seemingly consistent Shepherd story #240
Comments
Whatever we agree on should be documented in the README. |
Recall that nothing needs to be explicitly exported except for "dfn" type definitions. The rest export implicitly unless you use
This is a little hand-wavey. Unless there's a better definition type (like |
@tabatkins dictionaries, sequences, and interfaces are all types though. I don't think you can say one is a name and another is syntax. (Not really sure what an IDL name even is.) |
Yeah--I've found the mapping to be exceptionally challenging when doing the conversion to Bikeshed. Happy to help fix this once we settle on something that seems clearer. |
By "names", I'm referring to actual types.
Yeah, this is a particularly meta situation, it's not surprising that confusion abounds. ^_^ |
I'm not sure that's really helping. We have Currently IDL defines "record type" and "record" as things and does various other things for other types. It's still not clear to me what the strategy is for getting this all straightened out. |
What I'm saying is just that the word "record" is not one of the IDL definition types. Those are for things defined with IDL, not the concepts of IDL. In particular, the concept of a "record" is not an interface that is defined using WebIDL. (Technically neither are the primitive types, but I don't think it's sufficiently worthwhile for me to create a "primitive" definition type; we can just lump them in with interfaces because they act basically the same for our purposes.) (If I could do it over again I wouldn't have created separate types for interface/dictionary/other types that you can use in an arglist, as the point of separate types is to carve out separate namespaces, and those really live in the same namespace; you're not allowed to create a dictionary and an interface with the same name. I might still go ahead and merge them as aliases, but I need to develop some machinery to handle definition aliases first.) Given the above asides, the fact that "record" isn't an interface is even more obvious - it's 100% okay for me to write Same with "record type" - it's a Nobody's trying to write |
Thanks, that helps a lot! So I guess a remaining question I have is whether we should have separate definitions for types and instances. Generally when we define concepts we don't draw that distinction. E.g., the URL Standard defines URL records. It doesn't define a URL record type. And the new Infra Standard defines things like lists, maps, etc., but not list type, map type, etc. If we settle the type/instance question somehow I think I'm able to drive this to some kind of conclusion (and be finally able to land a patch to Fetch). |
I think it's fine for IDL to define types like "record type" or "long long". |
Reviewing #whatwg there seems to be a lot of confusion as to why "record types" and "dictionary types" and such are defined. Let me try to spell it out, as @bzbarsky has done previously. Web IDL defines a type system. In a type system there are at least two distinct entities: the types themselves, and instances of the type. The easy example is Web IDL also conveniently groups certain types into categories. The most obvious of these are "numeric types". But there are also a bunch of other categories, listed in https://heycam.github.io/webidl/#idl-types. Finally there are certain categories which you might not realize as categories, such as "dictionary type" and "record type" and "interface type" and "promise type" and "sequence type". See all the entries under https://heycam.github.io/webidl/#idl-types in the table of contents that end in "types". For example, the interface declaration The same goes for dictionaries and records. Each dictionary or record declaration creates a specific dictionary or record type. Dictionary types are given a name like The same goes for promise types and sequence types and nullable types and.... The sequence type This might be confusing because of the abbreviations we sometimes use (of which I've mentioned several above). But the actual theoretical foundation is well-founded and straightforward. I'm not sure what any of this has to do with Bikeshed, but I don't see why we would try to abolish the distinction between types and instances, or remove the |
What I'm saying is that everywhere else in standards we seem to be using terminology just like "5 is a long long". E.g., "« y, z » is a list". I don't like the inconsistency and I think we should either define a type system and consistently apply that everywhere (probably driven by Infra) or use the pattern that has worked well thus far outside of IDL. |
I guess I just have to disagree then. There's no inconsistency between my above outline and those two terminology uses. |
Disagree with what? Do you agree that we don't have a dfn for "list type" or "URL record type"? |
We indeed don't, because talking about them is not useful. In IDL, it's very useful to talk about the type system, to group the types together, to contrast them, etc. I disagree that we need consistency here. |
There's two reasons why I think it matters:
|
I strongly disagree. We need separate specification types, which can contain vague things, and IDL types, which can only contain things from the IDL type system.
Yes. This seems unrelated to the discussion here. |
Why though? Neither enforces the constraints and both operate in the same way.
Not really. I'm saying we need a general strategy since there will be convergence over time. You're saying it's fine to have separate strategies for IDL and the rest of the ecosystem. |
The constraints are enforced by the Web IDL type system! Yes, people can write specs that violate the Web IDL type system. But then it's just an invalid spec that's not implementable in browsers. In contrast, an Infra list can contain things that aren't Web IDL types, or multiple things of different types, or...
In general it's fine to have separate strategies for separate ecosystems. E.g. JavaScript, IDL, Dart, WASM, and spec-land all can have different type systems, and in each of them we can use the terminology we find most useful. There's no gain in trying to shoehorn everything into the same mold. |
Only at the boundaries (and that would continue to be true if we just use lists). If you create a new sequence in an algorithm step its items are not typed whatsoever.
I guess I don't really those as separate. And as I said, I see them converging. |
That's just not true. It's not possible to create a sequence without choosing which sequence type you are using. And then any manipulation of it must follow the rules of the type system. |
From HTML:
There's no type there. |
Yes there is; it's unrestricted double. |
Again, that's at the boundaries. Nothing in prose indicates that and that is where the sequence is created. If we used list there instead it wouldn't matter. |
Adding @tabatkins's comments on irc below:
|
@tobie You'll want to properly code-span some of those bits; there's several "sequence"s in there that are actually |
Note that "long long" is a type (kind-2), but "record type" is not - it's a kind-3 type, and instances of it (like I make no judgement on whether or not it's useful to refer to the kind-3 types; I suspect it is. The point of this thread was just to establish what definition type they should have, and if possible establish generic rules for determining this sort of thing. I think that's been accomplished. |
@tabatkins fixed. sorry. |
I don't think |
Anne, what you're proposing would be a complete overhaul of Web IDL, which has a strong foundation in type theory right now and relies on the guarantees it provides during all of its algorithms, not just at the boundary. The whole point of Web IDL having IDL -> JS conversion rules is because it's converting from one well-defined type system to the other. Without that the whole enterprise becomes ill-founded. |
There certainly is in implementations: the actual thing representing that record is typed as a map from DOMString to DOMString. I thought that this was also the case for spec-land in the sense that adding something other than a DOMString->DOMString mapping to such a record was an invalid thing to do, just like adding a Document to a |
It's certainly not something you should do, but as far as I can tell there's nothing that prevents it. We don't define operations for manipulating sequences and records and such that ensure these things. We typically do this kind of thing by convention. E.g., we have "ASCII string" for a string where we "guarantee" to not put anything in that is outside the range U+0000 to U+007F. You can implement that as a typed thing, but the specification doesn't really. It just says it's an ASCII string and treats it like a string for all intents and purposes.
There's nothing that would observably change, as far as I can tell. And we'd end up with less concepts and more reusable operations. |
Well, yes, but...
If we did, using those would be just something someone "should" do. Nothing would prevent a spec from directly poking the sequence/record guts and putting the wrong thing in there, right? In other words, at some point we always bottom out in "spec authors should not do the things they should not do". We just need to make it clear what those things are. |
I haven't suggested anywhere we should drop the conversion rules. I've asked two things:
|
The way Bikeshed annotations are used is rather weird.
Some types are exported (enumeration types), some are not (dictionary types, callback function types).
Some types are labeled dfn, some are interface, some are dictionary. E.g., sequence is an interface, but record is a dictionary.
Some types are co-located with their values (records, it seems like), others are in different places (dictionaries).
What's the strategy here?
@tabatkins any advice?
The text was updated successfully, but these errors were encountered: