algorand/pyteal

Overload `+` to Concat byte strings

Opened this issue · 2 comments

Problem

Make it more natural to add byte strings

Solution

define the + operator on the abi.Bytes class to do concat

A large barrier to this is the fact that we need to know at compile time whether the types are bytes or uint64 -- if bytes, use concat; if uint64, use +. But there are situations in which we cannot know the type of a value at compile time, e.g. when reading from local/global state, when loading the scratch space from a previous transaction, or (and this is something we have the power to fix) when accepting an Expr subroutine argument.

Another issue I am aware of deriving from #369, how are we handling case for Bytes("bytes-a") + Bytes("bytes-b")? Do we expect resulting to be Bytes("bytes-abytes-b"), or something else? I remembered we contain quote sign in bytes tho.