Open annevk opened 8 years ago
This blocks https://github.com/whatwg/fetch/pull/412 by the way.
Bikeshed's bleeding edge is broken right now, see: https://github.com/tabatkins/bikeshed/issues/867.
What is the difference between record and record type.
I don't know. We seem to have this for some types but not all. Unless there's a good reason to have both, we should probably clean it up.
@jyasskin was this copypasta or intentional?
A record is a thing of that a key-value mapping.
A record type is a type whose values are records.
The difference is the same as the difference between "long" and "5".
I don't really get the analogy.
5 is an instance of a long, sure.
But "record" is not an instance of a record type. A specific record, sure, but the word record by itself is not.
Anyway, I'm going to submit a PR to at least export mappings since that's blocking Fetch from using records.
Closed via #239 and https://github.com/heycam/webidl/commit/274117f761b5366a8ac88187ddb00089f8a63cd3.
I didn't close this intentionally. I'd still like to figure out the difference. Also, if they indeed turn out to be distinct somehow we should probably export both of them.
A specific record, sure, but the word record by itself is not.
I think "a record" would be "some instance of some record type", at least for me.
"the record" would be "a specific instance of some record type".
I'd be interested in how this is actually being used in context.
https://github.com/whatwg/fetch/pull/412/files "if object is a record, then for each mapping (key, value) in object"
Anyway, you're right, and ECMAScript does the same kind of thing describing its types: https://tc39.github.io/ecma262/#sec-list-and-record-specification-type.
Although ECMAScript does not seem to use a distinct <dfn>
for the type and instance.
So do we want a <dfn>
distinction between type and instances? And if so, should they all be exported?
if object is a record, then for each mapping (key, value) in object
In that case the intent is "if object is an instance of the record type", just like saying "if object is a Headers object" would mean "if object is an instance of the Headers interface type" or so....
Just to be clear, the language I used in whatwg/fetch#412 is adapted from the language in Web IDL spec itself. For instance:
2.11.25. Record types — record<K, V>
The order of a record’s mappings is determined when the record value is created. ... In language bindings where a record is represented by an object of some kind, passing a record to a platform object will not result in a reference to the record being kept by that object.
That is pretty much analogous to other IDL types as well.
dictionary identifier {
type dictionary_member_identifier;
};
In this case, identifier
is a dictionary type, while an instance of it would be a dictionary.
Yeah, I think your PR is fine.
I'm mostly wondering about the distinction between types and instances, but maybe the distinction only matters if there's syntax for types. E.g., the URL Standard defines URLs (not talking about the IDL interface here). Arguably they're a type, but we don't really make that distinction explicit.
The other thing here is that what IDL has as definition for "record" is the heading that says "record types". So even if there's a valid distinction between the two, the current setup doesn't really illustrate that I think.
I don't understand https://heycam.github.io/webidl/#idl-record. The heading is a dictionary definition (not exported). Then we have record type (exported). Then we have mappings (not exported, for=record).
What is the difference between record and record type? Why is mappings for=record and not for="record type"?
And can we export mappings?
I was trying to clean up some of this, but got