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

problem with zero-length sequences #4

Closed
gamorris opened this issue Nov 6, 2016 · 0 comments
Closed

problem with zero-length sequences #4

gamorris opened this issue Nov 6, 2016 · 0 comments

Comments

@gamorris
Copy link

gamorris commented Nov 6, 2016

I'm getting:

> (cl-pack:unpack "a0" "" :consumed 0)
0
NIL
> (cl-pack:unpack "a0" "zyxw" :consumed 0)
"z"
1

I think ideally it should be:

> (cl-pack:unpack "a0" "" :consumed 0)
NIL
0
> (cl-pack:unpack "a0" "zyxw" :consumed 0)
NIL    ; or maybe "" ?
0

I came across this when I was trying to decode a length-prefixed list of structures. I was trying to use a pattern like "l/(CCCl/a)". For some of my input data the list has length zero, so the input string is effectively equivalent to (cl-pack:pack "l" 0). I.e., ultimately I would like for this to work: (cl-pack:unpack "l/a" (cl-pack:pack "l" 0)) (e.g. return nil). At the moment I get a type error: The value NIL is not of the expected type NUMBER. (Running on Clozure CL on a Mac.)

Looking through the code it looked like the "a0" issue is likely the cause of "l/a" with a zero length giving an error.

This is not critical for me...I already coded a work-around. Simply a nice-to-have. (If I have some spare time I will see if I can come up with a patch myself. In the mean time it seemed worth reporting.)

Thanks!

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