Glaze as a reflection library #1379
Replies: 3 comments 9 replies
-
@fregate I've recently made Glaze even better for developing new formats. Features like Anyway, can I add you as a collaborator to Glaze? You could then pull Glaze, make a branch for Erlang from your code, and then create a pull request. I can look over your pull request and offer tips/explain the architecture more. Reading is typically more complicated, so writing should be straightforward. Also, the core reflection utilities in Glaze have become even more separated from formats since version 3, so your ideas here of splitting out utilities (reflection vs serialization) is very much a focus. |
Beta Was this translation helpful? Give feedback.
-
Hello, @stephenberry ! I've started some refactoring for support new format and go deeper and deeper. My first objective, of course is the new format, but while adding it, I've realized that there is some new necessary (from my point) changes I suggesting to make. For example make This is my first commit to change And second point like separate writer and reader like some entities, with own options. After that you can easily write something like beve_to_json, but with any formats you want (csv_to_beve, beve_to_erlang and so on). And according to my first, make error_code just ints, not enum, because many error are format specific and if split every format to separate space, base on core, extending enum is a wrong way to handle core and new formats. This is my first thoughts. What do you think about? I saw you started discussion about v5 API changes. I can write these thoughts there. |
Beta Was this translation helpful? Give feedback.
-
Ok. Thanks. I will write my thought about new But my second point was also about it. Try to be more clear. Right now, If we think about writers, than write to struct is one of possible writer, like "typed_writer". With "json_writer" you can write to json, you can write to beve with "beve_writer" and etc. Same API for all. But different writers. And different options. And this actual and for readers. You read from some data-stream and write to other format (even to data-stream with, for examlpe, prettifier), like "json_reader(input)" -> "json_writeropts:pretty(output)", or "beve_reader(input)" -> "json_writer(output)". No need to store in some external struct, because you don'y use a "typed_writer". For "typed_writer" it is like "json_reader(input)' -> "typed_writer(struct_instance)". So a new syntax will like...
and of course, you can create some helpers like PS I read this and think, this is very messy ) |
Beta Was this translation helpful? Give feedback.
-
Hi @stephenberry !
I've really enjoyed using glaze as a json parser (and serializator, for sure).
For my project I have a few formats to receive and serialize to json, for example. One of these formats is Erlang binary term format. And I've realized that my current library is too... ugly, I guess, and slow in comarsion with glaze.
So I try to made glaze-reflection as underlying library for Erlang format and it works! I've made only a few changes in glaze to handle new format. But it works (only for read at this moment).
Do you think about split glaze (in fact it already splitted in core, json and beve) to "reflection library" and "format parsing"?
In any case, I put my repo here - If you would be so kind to check my glaze patch (thirdparty/glaze.diff) and applicable it to main repository (or make PR is better way to discuss these changes?)
https://github.com/fregate/termlib/tree/reflection
Thanks in advance
PS My current lib is, like, proof of concept (and I think, some constructions with template magic I'm not fully understand), but it works and I will improve it (writing, at least)
Beta Was this translation helpful? Give feedback.
All reactions