Skip to content
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

Hex literal #60

Merged
merged 4 commits into from
Mar 24, 2023
Merged

Hex literal #60

merged 4 commits into from
Mar 24, 2023

Conversation

barnjamin
Copy link
Contributor

@barnjamin barnjamin commented Jan 29, 2023

Its often convenient to declare some large byte string that is not in the ascii range, this allows a 0x... literal declaration for bytes

const bytes bignum = 0xffffffffffffffffffffffffffffffff

needs docs

tealish/nodes.py Outdated Show resolved Hide resolved
@fergalwalsh
Copy link
Collaborator

I have always used byte escapes for this "\xDE\xAD\xBE\xEF". I thought raw bytes usage wouldn't be common enough to warrant special handling of this but both you & @pbennett want this. I'm ok with this. It's probably easier to read if you know some particular hex byte sequences.

Would you plan to add all of these formats though? https://developer.algorand.org/docs/get-details/dapps/avm/teal/specification/#constants-and-pseudo-ops

Also do we want to support this format for int too? e.g const int TOTAL_SUPPLY = 0xffffffffffffffff

@barnjamin
Copy link
Contributor Author

Would you plan to add all of these formats though? https://developer.algorand.org/docs/get-details/dapps/avm/teal/specification/#constants-and-pseudo-ops

Not unless there is a very good reason, hex ought to be enough to get bytes in a const

Also do we want to support this format for int too? e.g const int TOTAL_SUPPLY = 0xffffffffffffffff

Maybe yes but probably no since an actual integer can be used. I think that notation is more suited for the bigint proposed in #56

@pbennett
Copy link

I have always used byte escapes for this "\xDE\xAD\xBE\xEF". I thought raw bytes usage wouldn't be common enough to warrant special handling of this but both you & @pbennett want this. I'm ok with this. It's probably easier to read if you know some particular hex byte sequences.

Does Tealish actually support this?? It definitely isn't documented if it does. I still prefer the explicit hex over \xFF per-byte escaping though - particularly for blobs of bytecode where I have it now.

@fergalwalsh fergalwalsh merged commit 483cb7a into tinymanorg:main Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants