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

Consider syntactic sugar for "slice" functionality #170

Open
mr-zwets opened this issue Nov 11, 2023 · 1 comment
Open

Consider syntactic sugar for "slice" functionality #170

mr-zwets opened this issue Nov 11, 2023 · 1 comment

Comments

@mr-zwets
Copy link
Member

We should consider adding syntactic sugar for "slice" functionality

so instead of bytes stateItem = fullState.split(4)[1].split(10)[0];
it would be bytes stateItem = fullState.slice(4,10);

suggesting the name slice because substr could be confusing working on bytes (and was previously the opcode name for OP_SPLIT)

@mr-zwets
Copy link
Member Author

this would also simplify part of the anyhedge contract

        // Extract previous message's content sequence.
        int previousSequence = int(previousMessage.split(8)[1].split(4)[0]);

        // If the "content sequence" is negative it represents metadata rather than a price message
        // and cannot be used inside the contract.
        require(previousSequence > 0);

        // Extract settlement message's content sequence.
        int settlementSequence = int(settlementMessage.split(8)[1].split(4)[0]);

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

No branches or pull requests

1 participant