Add "call-by-need" parameters evaluation #17881
riiswa
started this conversation in
Feature Requests
Replies: 0 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Consider the following function:
With the lazy parameters, if we pass in parameter y the following block:
{println("Hello World"); 1}
, it will be evaluated 0 or 1 time, unlike the call-by-value which evaluates 1 time and the call-by-name which evaluates 0 or 2 times.This behavior is possible in Scala in the following way:
I think it would be useful to have in Scala 3 the keyword lazy for function parameters.
Beta Was this translation helpful? Give feedback.
All reactions