Support for lazy let or lazy const in order to save execution units by default. #290
Closed
matiwinnetou
started this conversation in
Core language features
Replies: 3 comments 1 reply
-
Just to help to illustrate this from real world example as I am doing in order to achieve lazy effect I have to do this:
this feels like a nightmare to me, lazy const would totally solve this. However, needless to say this is post alpha, post beta. Obviously there are more important features, this is ergonomics and clean code feature. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Will be handled automatically by items 2,3,4 in #135 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As I found out in Aiken / UPLC everything is evaluated eagerly but this can lead to execution cost bloat for many contracts.
Consider the code:
It makes absolutely no sense to check if funds are available so we could as well write this code like this:
lazy let would in fact be like calling function and putting parameter there once or even better once we have support for const in functions it should be a lazy const:
See discussion: #286 - regarding const in function scope instead of only allowing let (mutable and overshadowable).
Beta Was this translation helpful? Give feedback.
All reactions