Re: [heycam/webidl] No seemingly consistent Shepherd story (#240)

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 `long long` is a type, and `5` is an instance of the `long long` type. (More precisely: "the IDL `long long` value that represents the same numeric value as `5` is an instance of the `long long` type." Less precisely: "`5` is a `long long`".)

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 `interface Foo { }` creates the type "the interface type `Foo`", often abbreviated to just `Foo`. This is an interface type. An instance of the interface type `Foo`, often abbreviated to "a `Foo` instance" or "a `Foo`", is an instance of the type. This is exactly analogous to the `long long` + `5` situation above.

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 `dictionary Foo {}` and records are given a name like `record<K, V>`. Any given dictionary or record will be an instance of a specific dictionary or record type.

The same goes for promise types and sequence types and nullable types and.... The sequence type `sequence<long>` is distinct from the sequence type `sequence<Node>`. Any given sequence will be an instance of one 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 `<dfn>`s from one category or another.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/240#issuecomment-261797036

Received on Sunday, 20 November 2016 18:54:38 UTC