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

SIP specifying Clarity slice function #76

Closed
njordhov opened this issue Jun 27, 2022 · 3 comments
Closed

SIP specifying Clarity slice function #76

njordhov opened this issue Jun 27, 2022 · 3 comments

Comments

@njordhov
Copy link

I propose a SIP to specify a slice function for Clarity, building on the proposal in clarity-lang/reference#42 expanded with the insights of stacks-network/stacks-core#3149. There is a prototype implementation of such a function in the next branch that can be improved on.

@njordhov njordhov changed the title New SIP specifying Clarity slice function SIP specifying Clarity slice function Jun 27, 2022
@obycode
Copy link
Contributor

obycode commented Mar 6, 2023

Can this be closed now with SIP-015?

@njordhov
Copy link
Author

njordhov commented Mar 6, 2023

You may consider leaving it open as a candidate improvement for the next version of Clarity. The alternative design with last argument being the length of the result sequence offers a compelling alternative to the contrived expressions that typically results from the slice? function in SIP-015.

For example, consider this expression to just take the first three elements "abc" from a string while having the result properly typed as a (string-ascii 3):

(unwrap-panic (as-max-len? (default-to (list) (slice? "abcdef" 0 3)) u3))

With the proposed slice function, this would be written as below (with the last argument being the length of the result):

(slice "abcdef" 0 3)

@jcnelson
Copy link
Contributor

jcnelson commented Mar 6, 2023

Can this be closed now with SIP-015?

Yes it can.

You may consider leaving it open as a candidate improvement for the next version of Clarity.

Please open a specific issue for an alternative slice design. Thanks!

@jcnelson jcnelson closed this as completed Mar 6, 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

No branches or pull requests

3 participants