[Exercise] implement variable-length-quantity exercise#1053
Conversation
|
Hi, thank you for translating this exercise to C! I just noticed a few things:
Otherwise this looks good!
AFAIK we haven't discussed that yet for the C track. Its main purpose is to prove that the exercise can be solved. But in my opinion it should be a "good" solution, that's correct, somewhat easy to read, idiomatic, and reasonably efficient.
Personally I would prefer 32-bit integers, I think that would match the instructions a little bit better ("* for this exercise we will restrict ourselves to only numbers that fit in a 32-bit unsigned integer*"). But I can live with 64-bit integers. But (disclaimer) I'm not a maintainer of the C track, I have no vote here. Just to spare the maintainers some time: The makefile and test framework are identical to the other exercises. The |
|
Thank you for submitting @Wiguwbe . Good review @siebenschlaefer . |
- extend header guards; - explain better the functions in the headers; - use `const` for array inputs; - use `size_t` for array lengths; - rename input param `buffer` -> `bytes`; - disable most tests (enable only first of each test group); - use hex assert variants; - remove SQLite section; - use 32 bits integers (vs 64).
|
Many thanks @siebenschlaefer for the very good review indeed. I believe I have addressed all of the items. I kept it on a separate commit for ease of reading, I can squash it into the previous one if it preferable later. Let me know if the changes satisfy.
I never really did any C code professionally, or have it reviewed, so I'm not sure what "good"/idiomatic/easy to read code looks like 😄 . I'll see about improving tomorrow, hopefully I won't make it worse, but if it's not a blocker I'd say to not wait for me. |
making it more clear that encoding uses a LIFO
|
Thanks! |
Hello,
A few days ago I was trying to create a encoder/decoder for SQLite's
Varints. Instead of implementing the tests by hand, I searched for already implemented tests.I stumbled upon Exercism and the VLQ exercise in Python. As it was not implemented in C, I decided to port it. Hopefully someone will find it fun/useful as well.
Note that this is my first time contributing to (or even using) Exercism.
The test generation was automated using the
canonical-data.jsonas input. It's a relatively specific script (and implemented in Perl), but I'm attaching here still:gen-tests.pl.gz (gzip-ed so that github accepts it)
I have a couple questions for the reviewers:
example.cmay no be very reader-friendly. Is it expected to be read by someone or is it just to test the tests?uint64_tfor the decoded integers, but it's not expected to have integers bigger than 32-bits. Is it preferable to use 32 bit integers?