fluent: add qp, a different spin on quip #138
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is what I came up with, building on top of Eric's quip. I don't
want to waste too much time naming this, and I like two-letter package
names in place of dot-imports, so "qp" seems good enough for now. They
are the "strong" consonants when one says "Quick iPld".
First, move the benchmarks comparing all fluent packages to the root
fluent package, to keep things a bit more tidy.
Second, make all the benchmarks report their allocation stats, without
having to always remember to use the -benchmem flag.
Third, add a qp benchmark.
Fourth, notice a couple of potential bugs in the quip benchmarks, and
add TODOs for them.
Finally, add the qp API. It differs from quip in a few external ways:
No error pointers. Instead, it uses panics which are recovered at the
top-level API layer. This reduces verbosity, removes the "forgot to
handle an error" type of mistake, and does not affect performance
thanks to the defers being statically allocated in the stack.
Supposed better composition. For example, one can use MapEntry along
with Map to have a map inside another map. In contrast, quip requires
either an extra layer of func literals, or extra API like
AssignMapEntryString.
Thanks to the points above, the API is significantly smaller. Note
that some helper APIs like Bool are missing, but even when added, qp
should expose about half the API funcs taht quip does.
This is the first proof of concept. I'll probably finish adding the rest
of the API helpers when I find the first use case for qp.
Benchmark numbers, with perflock and benchstat on my i5-8350u laptop: