This is motivated by #61's requirement to have code that reads in JSON. Right now all structures do not have defined representation, making it impossible to use JSON.parse
I propose adding a representation mode:
struct S repr(.json) {
field: int,
other: float,
}
// alternate
struct(.json) S {
//
struct S(.json) {
The repr clause takes a comptime enum (#117) value saying what representation shall be used.
enum Representation {
auto,
json,
}
instead of following what zig has with extern struct, i think a better plan is to make this an enum, and let us explore more representation options. perhaps there can be one that represents it as a JS object with camel cased keys, since ix field names in my head are snake case.
Prior art on using a comptime enum like this can be seen in zig with callconv, align, and addrspace.
Milestone: 0.2.0.
Rust-y syntax for this:
#[repr(json)]
struct S {
field: int,
other: float,
}