-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Struct and class support #1
Comments
Maybe: struct Foo {
@bind("renamed")
string _blah;
@bind string name;
@optional string age;
int ignored;
} ? |
Or better: struct Foo {
@bind("renamed")
string _blah;
@bind!int string test; // On json this is a int
@bind string name;
@optional string age;
int ignored;
} to support get and as |
I think that binding should be default for a field. Maybe that is the default and could be changed with a struct UDA:
and
not sure...just an idea. |
What i don't like about bound-by-default is that - for example - if you add a new property it is bound automatically and probably you don't remember this (in your example all annotations are optionals). Maybe this sounds better. Version for impavid: @autobind
struct Foo{ ... } Safer way: struct Foo
{
@bind("user_age") @default(18) // If there's a default it's optional (and viceversa)
int age;
} |
You don't like bound-by-default because it might brake existing code not supporting a newly added field? You got a point with that. It could be fixed by making all fields @optional by default. Keeping the @Bind for fields that must be there and have a new @ignore for fields that should be ignored. That would make all structs/classes work out of the box with no annotations but could be annotated to make thing more specified if needed. |
also works the other way around
Maybe even introduce a UDA for optional fields:
The text was updated successfully, but these errors were encountered: