Skip to content

Conversation

@DynamicCake
Copy link
Contributor

This new API creates a decoder style interface for deserializing ValueRefs. Values have been removed.

@DynamicCake
Copy link
Contributor Author

Future me, don't forget that luerl_heap:get_table/2 throws an error when the table doesn't exist in state.

I should do more tests on how lua state actually gets passed
through decoders since using vibes isn't the best idea for a library.
Also deserializing something with deser.run shouldn't mutate state.
1. Deserializers should not mutate state
2. It is difficult to implement consistently
3. Custom decoders are harder to write
4. #(lua, data)
@DynamicCake
Copy link
Contributor Author

I have decided that after 38 commits, I am mostly happy with this APi.

@DynamicCake
Copy link
Contributor Author

DynamicCake commented Jan 7, 2026

For the record, the reason why I did not like the current decoding scenario is because

  1. Metatables don’t work, it is impossible to decode based on metatable contents
  2. Objects (when values have different types) are impossible to decode.
  • the way that I got decode.field to work here was to do an expensive O(n) processing which sometimes doesn't even get used.
  1. When returning things with multiple types in functions, it would be very tedious to decode.
  • For example: If call_function returns more than one type, a decode.one_of must be used + some kind of enum since lists must be homogeneous in gleam.
  1. Functions could not be decoded when in tables.
  1. Unneeded values get luerl:decoded which the gleam application doesn’t care about.
  2. When using this approach, decode.list cannot be used and always fails with no clear indication that glua.decode_table_list must be used instead.

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

Successfully merging this pull request may close these issues.

1 participant