Conversation
|
I absolutely love this. You've done a fantastic job! I look forward to seeing the tests that you add for this, and I'm also thinking ahead to reorganizing some of the existing serde code to use the new generate-serialize and generate-deserialize to add some inline arities to |
|
So I like the way you've chosen to introduce the type registry. It integrates well with the existing tools, and provides a way to do inline arities for serialize and deserialize in the future. One hesitation I have at the moment looking over the code is the use of ArraysCurrently in coffi the I also think that your compromise around using a record-like type with both map and array style accesses is appropriate and well-done. I might personally want to go the other direction with the serde registryThe serde registry as it stands with The first is just an observation and not a problem, that being that these functions all generate the equivalent of a The second is that these macros as they stand are unhegenic macro helpers. I think it would be appropriate for the multimethod to take in the symbol which will be used to refer to the segment. with-c-layoutFor the All the structs being passed over the C abi will most certainly use the Specifically though, if we remove the |
IGJoshua
left a comment
There was a problem hiding this comment.
I've got a few specific things in the review I'd like resolved or to discuss, and attached here I've got a few patches that I'd like if they were applied to the PR.
0004-Don-t-use-underscore-on-used-args.patch.txt
0003-Remove-duplicate-c-layout-implementation.patch.txt
0002-Fix-warning-about-defstruct-redefinition.patch.txt
0001-Use-a-once-only-impl-rather-than-with-typehints.patch.txt
Signed-off-by: Kristin Rutenkolk <kristin.rutenkolk@hhu.de>
Signed-off-by: Kristin Rutenkolk <kristin.rutenkolk@hhu.de>
Signed-off-by: Kristin Rutenkolk <kristin.rutenkolk@hhu.de>
Signed-off-by: Kristin Rutenkolk <kristin.rutenkolk@hhu.de>
…or strings Co-authored-by: Joshua Suskalo <joshua@suskalo.org>
Co-authored-by: Joshua Suskalo <joshua@suskalo.org>
|
to document a last touch: i moved defstruct can still be called from |
register-new-struct-deserialization
|
i actually just pushed another fix here: the introduction of |
|
I retracted the commit implementing boolean support from this PR and moved it to a different (draft) PR as requested by @IGJoshua |
|
🥳 |








[Note: I would consider this a draft PR, as I have not yet added tests (which could unearth some bugs and necessitate appropriate fixes).]Hi, this PR contains the addition of a
defstructmacro. It does the following:c-layoutdeserialize-fromandserialize-intoclojure.pprint/simple-dispatchserde registry
The "registry" is implemented via the multimethods
generate-deserializeandgenerate-serializewhich produce code to de/serialize the respective types. This removes indirection in the de/serialize code for types that use other types. i think in the original discussion we were on the same page, but thought the other meant something different. Thedefstructmacro adds implementations to the multimethods for the newly generated type.the generated type
The new type is generated via
deftypein the private functiongenerate-struct-record. This is an attempt to strike a middle ground between the two positions of the original discussion, although the result might be a bit odd:IPersistentVectorandIPersistentMap.nthas well as map-like methods likewithout(for e.g.dissoc).assoc, it supports both paradigms of indices-as-keys and membernames-as-keys. Practically speaking, if you use something likeassocwith a number as a key, it behaves like a vector (and will return a vector), otherwise like a map (and will return a map).foreachwhich can't support both paradigms, and it is therefore implemented as if it's a vector. The rationale here is that the value of the type is composed of the actual values of the members, not the associated names of the places of the values. If youmaporreduceover an object of this type, you will do so over the values of the members.with-c-layout
There was one implementation problem. Since padding was needed to be taken into account to allow for inline serdes, the new code for the macro needed to rely on
with-c-layout. The problem here is thatwith-c-layoutis in thelayoutnamespace which already depends onmem. As a stopgap solution i simply copied the function over as a private function. I would be in favor of actually deprecating thelayoutnamespace. for backwards compatibility thewith-c-layoutfunction inlayoutcould depend on the one inmem. Not only is thelayoutnamespace at this point somewhat anemic, it has also caused me trouble. I'm not sure if it's a bug, but due towith-c-layoutbeing inlayout, i ran into the problem that there are now two different:paddingkeywords, which i found confusing.tests & benchmarks
No tests or benchmarks exist right now. I don't expect the custom type to be slower than defrecord, but I want to test it.
Similarly, i do want to add a first set of tests for the de/serialization.