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

Why can't typed containers be nested? #73

Closed
ghost opened this issue Sep 19, 2015 · 3 comments
Closed

Why can't typed containers be nested? #73

ghost opened this issue Sep 19, 2015 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 19, 2015

I know typing will probably change in the next version, so this will be a moot point, but I’m still curious what I’m missing. It seems to me that something like

[ [ ][$][ [ ][#][U][2]
[$][i][#][U][3][1][2][3]
[$][i][#][U][3][4][5][6]

(that’s [ [1, 2, 3], [4, 5, 6] ] )

is unambiguous and I can’t think of an ambiguous counterexample.

@Steve132
Copy link
Contributor

Steve132 commented Nov 4, 2015

I'm pretty sure that typed containers can be nested. That was the final resolution of this thread #43

It resolved the "STCs must not contain other STCs" issue and said that what you just typed would in fact be valid.

In fact, UBJ (my C language parser) handles your case already.

Here is the relevant part of the spec: http://ubjson.org/type-reference/container-types/#optimized-format

yes it is possible for an array or object to define their type as ‘[‘ or ‘{‘ to signal that they themselves contain additional containers!

@ghost
Copy link
Author

ghost commented Nov 19, 2015

Then this rule in the spec needs to be clarified:

A container that specifies a type must not contain any additional type markers for any contained value.

It can be interpreted as “A container can have a ‘array’ or ‘object’ as its type, but those inner arrays or objects must not have types themselves”. If that’s not what it means, I actually have no idea what it does mean. Maybe that line should just be removed.

@Steve132
Copy link
Contributor

If that’s not what it means, I actually have no idea what it does mean. Maybe that line should just be removed.

It seems straightforward and means exactly what it says. It says that no type markers are inside the container for direct children, because the type is known (and must be constant) across the whole container type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant