Skip to content

Pack empty arrays as zero-length arrays#46

Open
Groterik wants to merge 1 commit into
msgpack:masterfrom
Groterik:master
Open

Pack empty arrays as zero-length arrays#46
Groterik wants to merge 1 commit into
msgpack:masterfrom
Groterik:master

Conversation

@Groterik
Copy link
Copy Markdown
Contributor

It is point at issue, but it seems like it is better in terms of compatibility with other languages. For example, msgpack-c provides default adapters for vectors and strings that throw an exception in case of nil value deserialization. It is ok to send c++ empty std::vectors, std::strings, std::vectors of std::strings, etc, packed by default to the dlang application and get dlang empty strings, arrays[], etc, but not the other way around. That's why communication between dlang-app and cpp-app via msgpack is complicated. Also python implementation of msgpack produces zero-length arrays. In addition, zero-length arrays are serialized into one byte as well as nil value.

@repeatedly
Copy link
Copy Markdown
Member

Thanks!

But this breaks backward compatibility.
I have a plan to implement new spec and this is a chance to merge this PR.
Please wait.

@repeatedly
Copy link
Copy Markdown
Member

I'm reconsider this issue.
In C++, std::vector and other containers are struct so they can't handle nil properly.
But In Java, C# or other languages, they can handle nil for container object.
So this change is not good for almost languages.

There are several approaches to resolve this issue.

  • msgpack-c supports nil in containers. Maybe returns uninitialized container?
  • msgpack-d provides handleNilAsZeroSizeContainer like parameter to switch behaviours.

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

Successfully merging this pull request may close these issues.

2 participants