You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #8226 it was agreed that Process::Status is a value type and should be implemented as a struct, not a class.
This PR was never merged, though.
Maybe there are other types that fit that profile as well. It's important to note that not any immutable type should automatically be a struct. Process::Status is just a wrapper around a 32-bit integer, which makes a lot of sense (cf #8226 (comment)).
OAuth::RequestToken might be considered for a struct as well, but I think it's less obvious.
Changing a public stdlib type from class to struct would obviously be a breaking change. The question is whether it has any relevant impact. I think it probably won't be a big problem as it's only gonna have an effect for reopening the type. Reopening stdlib types is not particularly encouraged, so this might be an acceptable change.
In any case, this should be considered for Crystal 2.0 where such a breaking change is definitely possible. Maybe we can also fit it into a minor release.
For Crystal 2.0, I think one idea could be to have everything be a class. If you want something to have struct semantics you can use an annotation, like @[Struct]. That way when you reopen a type, it's always using class and there's less chance for a breaking change.
Of course there's still module, but changing things from class to module is less common.
In #8226 it was agreed that
Process::Status
is a value type and should be implemented as a struct, not a class.This PR was never merged, though.
Maybe there are other types that fit that profile as well. It's important to note that not any immutable type should automatically be a struct.
Process::Status
is just a wrapper around a 32-bit integer, which makes a lot of sense (cf #8226 (comment)).OAuth::RequestToken
might be considered for a struct as well, but I think it's less obvious.Changing a public stdlib type from class to struct would obviously be a breaking change. The question is whether it has any relevant impact. I think it probably won't be a big problem as it's only gonna have an effect for reopening the type. Reopening stdlib types is not particularly encouraged, so this might be an acceptable change.
In any case, this should be considered for Crystal 2.0 where such a breaking change is definitely possible. Maybe we can also fit it into a minor release.
Related: #13014
The text was updated successfully, but these errors were encountered: