-
Notifications
You must be signed in to change notification settings - Fork 182
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
Get rid of bytes type #258
Comments
Just a quick addition after discussing that with @g-r-a-n-t The one tricky thing is that from an ABI perspective One idea how to deal with that is to say that in Fe It seems to me that this would feel consistent as far as Fe is concerned at the expense of having an inconsistency with the general Ethereum ABI. |
One thing that I considered after our discussion was how this would work with structs. For example:
the So maybe we would want to do something like this:
I'm wondering if using annotations to inform the encoding of data is something that would be useful in other situations too? |
And it would be unreasonable to use
Yes, that could be reasonable. I wonder how often that would become an issue. If people would end up having to use these decorators a lot I'm inclined to say we should look for another solution (including keeping
I do think these annotations will come in handy to deal with the snake/camel case conversion e.g.
This would then ensure |
Yeah, I think forcing people to use a larger type for this would be too heavy-handed.
Good point, camel casing is another problem that this could solve. People may also choose to use non-standard types of encoding, which could fit nicely with annotations.
|
This happened |
Remove bytes type
Disclaimer: There may be very good reasons to keep the
bytes
type so I'm creating this issue in anticipation of push back to see if anyone can bring up good reasons to keep a dedicatedbytes
type.Today, Fe has a primitive
bytes
that isn't actually well integrated in the language yet and I'm going to argue that we should stop right here and don't try to do so. Instead, let's follow Rust which also doesn't have a nativebytes
type in the language.If one wants to express a single byte the native type to do so in Rust is
u8
. If one wants to express two bytes, it would be[u8; 2]
. A fixed size array of twou8
s.If we write out a byte string such as
b"foo"
in Rust the type that the compiler assigns is&[u8; 3]
.I believe the only reason why Fe has a
bytes
type is because of its Python origin but that seems to be rooted in the fact that Python lumps all numbers together and doesn't have a way to express a single byte asu8
.To me it seems that keeping a seperate
bytes
type only introduces friction without any clear benefits. E.g. we would probably want a way to cast anu8
tobytes
likebytes(5)
but we would then also have to go further to introduce casting fromu8[n]
tobytes[n]
. I'm having difficulty to justify why would want to introduce all this whenbytes
seems to be a synonym foru8
at best.The text was updated successfully, but these errors were encountered: