-
Notifications
You must be signed in to change notification settings - Fork 139
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
Parameterised Lists -> Lists #839
Comments
I ran into an issue recently where I wanted to define a new header as a List. I ended up choosing Parameterized List instead. Even though I didn't have any parameters yet, this seemed like a better way to future-proof it. I'm a proponent of this. |
It's graceful and DRY, but the javascript people probably won't like it. I'm also in a museum in Darwin, a thousand miles from my computer, so I'm not digging very deep right now. Within a list, is there a difference between an item, and a parameterised item with no parameters? And if so, how are they distinguished in the serialisation? |
I don't think so -- I think it's just "list items can have parameters." @annevk any thoughts? Enjoy the North -- hopefully it's warmer than Melbourne :) |
My +1 goes to adopting this too. It's simpler, and more future-proof. Regarding similarity to JSON, it's my understanding that sh-param already requires a not-so-straightforward mapping. Because a JSON object does not have a concept of "a value associated with attributes." I think there are at least two ways to map an parameterized item to JSON. One is to use an array, like |
I'm having trouble wrapping my head around the proposal. I think that it means that headers can be more expressive and complex, which sounds great to me! Would you mind putting up an example of what this change would enable? |
I don't think there's any change in the serialisation -- it's just getting rid of the distinction between |
Then I really don't understand the proposal. :) Going back to the original issue:
I think this means that
I think this means that Is that about right? |
Yes.
Yes. I'm saying that the serialisation doesn't change because this issue is depending on #816 and #797 to do the work for it; if they get in, it seems like a natural cleanup / consolidation to me. |
Got it. 👍 More expressiveness is good.
What about I assume parameter name (and dictionary item names) wouldn't change? That is, |
No to both of those, at least as I see it currently (I could be convinced, but it seems pretty complex). |
Allowing parameterized inner-list items would address the example in https://tools.ietf.org/html/draft-ietf-httpbis-header-structure-10#appendix-B.2. I think it could then be rewritten as:
|
I'm not against it, but let's see if we can declare victory on this step first :) |
Victory it is! I am defining a header whose value is probably(?) a parameterized list literally right now, and will happily change it to a list if/when this lands. |
OK. I might land the PRs for those two issues and do this, then submit a new draft after @bsdphk has a chance to look over it. I'll try to update the test suite and my implementation before submission to flush out any bugs, but it might have to wait until after (deadline is Monday). |
I think this is fine. We haven't really started looking into JavaScript types for these things yet and that still seems a little early to do as well. And even then we could offer convenience methods that return a lossy array (without parameters) if that turns out to be a common use case. (And it's indeed very likely you want to go from items to more expressive items, I've come across this a few times in the last couple months alone.) |
See PR #841 for a first pass at this. |
Also @evert wanted to make sure you saw this, as it's an API change. Thoughts? |
Seems like only positive feedback, so I'm going to merge, take another look in situ, and then perhaps get a new draft out. Thanks. |
Discussion on #816 and #797 makes me wonder whether it would be good to refactor Parameterised Lists to be just Lists -- i.e.:
Dictionary
List
andItem
.The obvious benefit here is simplification. Another benefit would be future-proofing headers that might need to elaborate on their list items in the future; they can just add new parameters as necessary.
The downsides I can see:
What do folks think -- worth it?
The text was updated successfully, but these errors were encountered: