nirum-lang / nirum

Nirum: IDL compiler and RPC/distributed object framework for microservices
https://nirum.org/
GNU General Public License v3.0
121 stars 28 forks source link

Optional default tag for union types #13

Closed dahlia closed 6 years ago

dahlia commented 8 years ago

If union types can set its default tag it would help backward compatibility e.g.:

record name (text fullname);
// The below record type can be migrated to the above union type:

// Pseudo code — syntax is just for example
union name
    = wastern-name (text first-name, text? middle-name, text last-name)
    | east-asian-name (text family-name, text given-name)
    | default culture-agnostice-name (text fullname)
    ;

The default tag is implicitly determined if the JSON object doesn’t have "_tag" field, which means the case a record type is refactored to a union type.

dahlia commented 6 years ago

Remaining things after PR #227: