Skip to content
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

Shepherd: difference between "record" and "record type" #233

Open
annevk opened this issue Nov 10, 2016 · 15 comments
Open

Shepherd: difference between "record" and "record type" #233

annevk opened this issue Nov 10, 2016 · 15 comments

Comments

@annevk
Copy link
Member

annevk commented Nov 10, 2016

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

Traceback (most recent call last):
  File "/usr/local/bin/bikeshed", line 9, in <module>
    load_entry_point('Bikeshed==0.0.0', 'console_scripts', 'bikeshed')()
  File "/Users/annevk/GH/bikeshed/bikeshed/__init__.py", line 196, in main
    doc.preprocess()
  File "/Users/annevk/GH/bikeshed/bikeshed/__init__.py", line 590, in preprocess
    highlight.addSyntaxHighlighting(self)
  File "/Users/annevk/GH/bikeshed/bikeshed/highlight.py", line 85, in addSyntaxHighlighting
    highlight(el, translateLang(lang))
  File "/Users/annevk/GH/bikeshed/bikeshed/highlight.py", line 27, in highlight
    widl = parser.Parser(text, IDLUI())
NameError: global name 'parser' is not defined
@annevk
Copy link
Member Author

annevk commented Nov 10, 2016

This blocks whatwg/fetch#412 by the way.

@tobie
Copy link
Collaborator

tobie commented Nov 10, 2016

Bikeshed's bleeding edge is broken right now, see: speced/bikeshed#867.

@tobie
Copy link
Collaborator

tobie commented Nov 10, 2016

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.

@annevk
Copy link
Member Author

annevk commented Nov 10, 2016

@jyasskin was this copypasta or intentional?

@bzbarsky
Copy link
Collaborator

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".

@annevk
Copy link
Member Author

annevk commented Nov 14, 2016

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.

@tobie
Copy link
Collaborator

tobie commented Nov 14, 2016

Closed via #239 and 274117f.

@tobie tobie closed this as completed Nov 14, 2016
@annevk
Copy link
Member Author

annevk commented Nov 14, 2016

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.

@annevk annevk reopened this Nov 14, 2016
@bzbarsky
Copy link
Collaborator

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.

@annevk
Copy link
Member Author

annevk commented Nov 14, 2016

https://github.com/whatwg/fetch/pull/412/files "if object is a record, then for each mapping (key, value) in object"

@annevk
Copy link
Member Author

annevk commented Nov 14, 2016

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?

@bzbarsky
Copy link
Collaborator

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....

@TimothyGu
Copy link
Member

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.

@annevk
Copy link
Member Author

annevk commented Nov 15, 2016

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.

@annevk
Copy link
Member Author

annevk commented Nov 15, 2016

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.

annevk added a commit that referenced this issue Nov 22, 2016
And also stop marking them up as Bikeshed IDL types since they’re not.

See also #233 and #240 though I don’t think this commit addresses
either of them fully.
tobie pushed a commit that referenced this issue Nov 22, 2016
Also stop marking them up as Bikeshed IDL types since they’re not.

See also #233 and #240 (although this commit doesn't address them fully).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants