-
Notifications
You must be signed in to change notification settings - Fork 664
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
Variadic numeric comparison operators #1628
Comments
love the fact this will make the language definition more consistent, and this will make for more concise than using
and probably not too hard to implement |
I have pretty strong reservations against this. There's not an obvious way to deal with the case where the items in the list are computed using a function that mutates state. For example:
What does By restricting comparison operators to be binary operators, we get less surprises, since there's already lots of language precedent for understanding how to evaluate |
This would not be introducing something we don't already have to be cognizant of with Clarity. Today, I can define this:
which I can call with:
The same concern would apply, and someone doing this would have to be pretty clear on how What it comes down to is having a strong language specification that defines how many times each function argument is evaluated, and in which order. And maybe it is, I just wouldn't know where that is. I've assumed that each parameter was evaluated once, from left to right, even if one is not being used (unless otherwise specified, i.e. Having this specification is important for people using the language, but also, possibly down the road, if someone decides to build a new implementation of the Clarity vm (bitcoin does have more than one implementation, same for ETH) so that no matter what implementation executes the contract, you'd get the same predictable result. Edited to add references to |
@jcnelson Consider that the actual problem has to do with using global variables and functions that mutate state for the arguments. How can Clarity be improved to avoid this foot gun for developers? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed. Please reopen if needed. |
In Clarity and typical for Lisp languages, algebraic numeric operators like
+
and*
are variadic, taking an arbitrary number of arguments. This allows for concise expressions like:However, Clarity's numeric comparison operators like
<
only support two arguments, while these typically are variadic in Lisp languages. Onlyis-eq
is variadic.Proposal: Make all numerical comparison operators variadic rather than limited to two arguments.
This would make Clarity more in line with other Lisp languages and support concise expressions like:
The text was updated successfully, but these errors were encountered: