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

Pack empty arrays as zero-length arrays #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Groterik
Copy link
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
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
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