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

replace this package with https://github.com/beacon-biosignals/MsgPack2.jl #30

Merged
merged 32 commits into from
Sep 9, 2019

Conversation

jrevels
Copy link
Collaborator

@jrevels jrevels commented Sep 5, 2019

Let's see how CI runs correctly here; seems like codecov/Travis are already set up so should work in theory

@jrevels
Copy link
Collaborator Author

jrevels commented Sep 5, 2019

Awesome, looks all green.

I'll wait for an approval here, then I'll merge and tag a v1.0.0 release (major version bump since it's quite a big code change, though I made sure to leave in deprecation paths where they seemed needed).

@jrevels jrevels requested a review from kmsquire September 5, 2019 14:29
Copy link
Collaborator

@kmsquire kmsquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for all of this work (seems tedious)!

I left a few minor comments. The only required change would probably be the version number bump in Project.toml.

Cheers!

Project.toml Outdated
version = "0.2.0"
uuid = "f3bf5812-ae52-11e9-182b-097c550858cf"
authors = ["Jarrett Revels <jarrettrevels@gmail.com>"]
version = "0.1.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version needs to be bumped here.

src/pack.jl Outdated
"""
function pack(io::IO, x)
pack_type(io, msgpack_type(typeof(x)), x)
return io
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if it's useful to return io here, or if nothing might be better?

I guess io would be better if packing things in a pipeline, but I'm not sure how common that is (or even if it's uncommon, if it's something we want to support).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing seems like a sensible return value here so I've gone ahead and made that change

error("no non-`AnyType` MsgPack mapping found for ", typeof(x), "; please ",
"overload `msgpack_type` for this type.")
end
return pack_type(io, tx, x)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases, pack_type returns the result from write() (an Int), while in other cases, the return value is nothing.

The same seems to be true for pack_format.

Since the return value doesn't seem to be used in any calls, this may not matter, but maybe it's worth always returning nothing?

Alternatively, if returning the result of write (the number of byte written), then some functions would need to accumulate those values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, good point - the return values of these functions (which are just meant to be internal) should probably be nothing. Just would require a bit of churn to refactor; I'll open a follow-on issue.

Copy link
Collaborator

@kmsquire kmsquire Sep 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be fine. How about just creating our own write function? Something like

function write(args...)
    Base.write(args...)
    nothing
end

(Probably simple enough that @inline isn't necessary?)

src/unpack.jl Outdated
elseif byte >= magic_byte_min(IntFixNegativeFormat)
return unpack_format(io, IntFixNegativeFormat(reinterpret(Int8, byte)), T)
else
invalid_unpack(io, byte, AnyType(), T)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable code? I guess it's good to keep it here to guard against developer error... ;-)

src/unpack.jl Outdated
elseif byte >= magic_byte_min(IntFixNegativeFormat)
return unpack_format(io, IntFixNegativeFormat(reinterpret(Int8, byte)), T)
else
invalid_unpack(io, byte, t, T)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable code?

elseif byte === magic_byte(Bin32Format)
return unpack_format(io, Bin32Format(), T)
elseif byte >= magic_byte_min(IntFixNegativeFormat)
return unpack_format(io, IntFixNegativeFormat(reinterpret(Int8, byte)), T)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I see these long lists, I really want a switch or match statement. (Of course, those exist in packages, and it's nice not to depend on unnecessary packages...)

Copy link
Collaborator

@kmsquire kmsquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. You can decide whether or not to put the write changes here or in a future MR.

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