mransan/ocaml-protoc

Could uint32 and uint64 types be tagged?

Closed this issue · 5 comments

Right now protoc turns uint32 and uint64 types into OCaml int32 and int64.

This is rather scary for (e.g.) financial apps because it's easy to miss and do something horribly wrong.

Rather than try to debate what unsigned integer library to use, I propose something more modest: perhaps we can do something simple like emit [`unsigned of int32] or [`unsigned of int64] in these fields?

While this would break existing code it would be fairly trivial to fix.

c-cube commented

What would [unsigned of int32] do?

c-cube commented

Ah I see, interesting. I think this can start with an option for the codegen binary, which could be opt-in, and later (breaking release) become opt-out.

btw: double the surrounding ` for [`unsigned of int32]

Oh, yeah, making it an optional arg for the codegen is a great idea.

c-cube commented

PR welcome then :)

If you want to be fancy, there could even be an option to use stdint or something like that for true unsigned types. That would probably remain optional though.