Where clause #465
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Created by: subhod-i
The
Whereclause is self-explanatory in the functional programming paradigm. In Sophia, writing independent functions which are used only once in a method will improve the readability of the smart contract.Created by: radrow
I don't like it for two reasons:
letdoesn'tNote that this is not Haskell; evaluation order does matter, and so this could lead to ambiguities.
Created by: subhod-i
Can the
letkeyword be used to assign a function to a variable in Sophia?This may not be a problem. You know the function you are calling is not somewhere in the smart contract but rather in the where clause that is attached to this caller function body.
Agreed
Created by: radrow
letcannot do it at the moment, but this is rather a missing feature. I would rather letletintroduce functions than implementwhere. We are actually considering fixing that.I have seen many abuses of it in Haskell and Purescript. In those languages this is especially confusing when people mix it with
let.Created by: radrow
We could possibly consider limitations to how
wheremay be used, eg only on toplevel functions, only non-stateful functions, no nesting, etc. But that would complicate the language, while being even less useful. Also, if you need so many auxilary functions thatletis unreadable, then maybe you should create a namespace? We are planning to introduce nested namespaces in the upcoming future, so that would be my way to go.Created by: subhod-i
I see your point.
letmight work in this case. Looking forward to thenamespacefeature. Feel free to close this issue!