This repository has been archived by the owner on Nov 5, 2023. It is now read-only.
Assignment =
expressiveness
#11
Labels
↻ breaking
Suggestions or fixes that are breaking changes in some way.
• enhancement
New feature or request
∆ feature
New feature suggestion
# prioritize
Issues that are more urgent than others
So assignments in languages throughout history have always been implemented as statements. But in the recent functional era of languages code have gotten more and more expressive based. Though assignment expressions returned their value for allowing code like below is nice.
I got the idea to fully combine assignments with pattern matching, making the expression return
true
orfalse
weather the "matching" was successful. This way we could also write code like thisand only use one operator for both assignment and comparison.
The
=
operator could therefore be seen as an infix operator evaluated right-to-left and updating the environment after matching every term in the expression, thus fulfilling the transitive property of equality. This would allow for code as show in the first example, AND in the latter.Then one problem arises. What if we would like a variable to obtain the boolean value of if two other variables were the same.
Because
=
would be an boolean infix operator with side-effects. Wrapping an expression in parenthesis would force that expression to evaluate first and then returntrue
orfalse
if the matching was successful, meaning the terms were equal or one variable were undefined and therefore defined with the value of the other terms value (true
), or the expression was not equal (false
).So, this code would be valid:
Linked to #12.
The text was updated successfully, but these errors were encountered: