-
Notifications
You must be signed in to change notification settings - Fork 53
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
Clear distinction between storing a value and storing a pointer in an interface #441
Comments
Why would it needs methods on non pointer receivers? |
@skejeton For consistency. For example, you can treat methods on non-pointer receivers as |
@vtereshkov But the value type interface isn't immutable/const. On a normal value type you can call methods with pointer receivers, which implicitly takes reference of itself. |
@skejeton On a value-typed |
@vtereshkov Makes sense, but this is about const/var, not imterfaces. Isn't it? |
@skejeton Interface methods should act exactly as the corresponding concrete type methods. They shouldn't expect a pointer to a const, for example. |
@vtereshkov i don't get it, why are we talking about consts? |
I think I understand what you meant now. Now that we don't have structured constants, do we need value typed methods? |
Umka could do it the same way as Go does. This would be more consistent than Umka's interfaces.
However, it would require two extra features:
A means of indicating that a type assertion with a value type has failed. For example, Go's type assertion syntax in separate from type casts. @skejeton proposes a new cast-like assertion in the form
^T(&interfaceValue)
that can returnnull
on failure.Methods with non-pointer receivers. See the Go example: https://go.dev/play/p/tQx7GNmhzDm
The text was updated successfully, but these errors were encountered: