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

VIP: Allow list of byte arrays #728

Closed
ElianaTroper opened this issue Mar 29, 2018 · 3 comments
Closed

VIP: Allow list of byte arrays #728

ElianaTroper opened this issue Mar 29, 2018 · 3 comments
Assignees
Labels
VIP: Approved VIP Approved

Comments

@ElianaTroper
Copy link
Contributor

ElianaTroper commented Mar 29, 2018

Preamble

VIP: 728
Title: Allow list of byte arrays
Author: Samuel Troper, [email protected]
Type: Standard Track
Status: Draft
Created: 2018-03-29

Simple Summary

Allow list of byte arrays.

Abstract

Currently, lists are not allowed for byte arrays. Say you wanted to represent 3 two byte pieces of data, you could use aByteArray: bytes <= 6 and use bytes 1 & 2, 3 & 4, and 5 & 6 as pairs to represent each of these pieces of data, but this is less intuitive to code, less readable, and requires good documentation to allow contracts to be easily readable.

Motivation

This is a limitation of the language, particularly in a space where storage limitations are important, that could easily be addressed. It would also greatly enhance audibility.

Specification

With #714:
someBytes: bytes[2][3]

Backwards Compatibility

Backwards compatible. The old workaround would continue to function, the new implementation would be new.

Copyright

Copyright and related rights waived via CC0

@jamesray1
Copy link
Contributor

jamesray1 commented Mar 30, 2018

I think it's better to just stick to someBytes: bytes[3] rather than someBytes: bytes <= 3. Less overhead, better performance. Note also: #714.

@jacqueswww
Copy link
Contributor

jacqueswww commented Mar 30, 2018

bytes[2][3] does seem ambiguous. The first [] sets the byte length and the second [] set the number of items in the list, but this is a rarer case, and therefore I am OK with it ;)

@jacqueswww
Copy link
Contributor

jacqueswww commented Jan 6, 2020

Tested; works now 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VIP: Approved VIP Approved
Projects
None yet
Development

No branches or pull requests

3 participants