nervosnetwork / molecule

Another serialization system: minimalist and canonicalization.
MIT License
36 stars 23 forks source link

Add syntax_version identifier to molecule #64

Closed eval-exec closed 1 year ago

eval-exec commented 1 year ago

This PR want to make molecule support syntax version identifier.

We can specify syntax = {version} now.

  1. If syntax_version wasn't specified, it would be 1 by default.
  2. All schema file you imported must have same version : a syntax = 1 schema file can't import syntax = 2 file, and syntax = 2 file can't import syntax = 1 schema file either.

@yangby-cryptape @driftluo @code-monad @zhangsoledad Invite you to review this PR.

doitian commented 1 year ago

Could you explain the motive to add syntax version?

eval-exec commented 1 year ago

Could you explain the motive to add syntax version?

It's like Protocol Buffers' syntax identifier, https://protobuf.dev/reference/protobuf/proto3-spec/#syntax

The "molecule primitive types #62" feature will add uint{8,16,32,64}, int{8,16,32,64} and bool as primary types, so we need the syntax identifier to tell molecule whether to treat these types as primitive types or not.

eval-exec commented 1 year ago

Rebased on master branch. Ready for review. @quake