-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Introduce concat or bytes.concat #10903
Comments
I don't think a global
(note that there are no quotes around |
Does |
Could the optimizer deal with that properly (now or ever) :-)? A |
The uses for |
What about defining the |
Could also consider other operators for concatenation, such as |
Other operators were suggested:
|
Decision from call: We also discussed the option to have |
@mijovic what is still left to do here? |
I think I didn't close the issue because there was still an open point about allowing |
I would say this is done. |
This came up frequently and has been recently discussed under #9829. One of the uses of
abi.encodePacked
is for it to perform concatenation.Many EIPs use snippets to explain the rules and many libraries rely on
abi.encodePacked
. The first impression is that they actually rely on the weird "encoding" it performs, but a closer look reveals that in many cases they only rely on the concatenation feature. In many cases the concatenation is used to add a prefix prescribed by EIP-191. An example for actual data encoding is EIP-712.While it is a bit unfortunate that standards (aka EIPs) rely on Solidity snippets, it is something we likely can not change, but we can improve the language so that confusion is also minimised in those standards. Having
concat
instead ofencodePacked
I think would go towards that. (I believe this confusion lead to libraries adding support for "encodePacked".)I propose to introduce
concat
which takes a variable number ofbytes memory
as an input and returns a singlebytes memory
.Question A: should it also allow fixed bytes (i.e.
bytesNN
) as an inputs, which are tightly packed and not zero padded? Or should we in parallel finally implement conversion between fixed and variable bytes types?Question B: should we start adding functions as members of types, i.e.
bytes.concat()
? If yes, is that a breaking change? I guess it is, because libraries could extend those types already.The text was updated successfully, but these errors were encountered: