Status/Resolution/Reason: To Fix//Investigate
Reporter/Name(from Bugbase): Luis Majano / ()
Created: 04/04/2018
Components: Language
Versions: 2016
Failure Type: Others
Found In Build/Fixed In Build: /
Priority/Frequency: Normal /
Locale/System: /
Vote Count: 7
I would like to propose the ability to mark variables as **lazy** to delay their eager evaluation by the compiler. This can be a great asset for performance and optimizations as we avoid the applicative order of the language where functions and variables are eagerly evaluated.
Languages like scala support this and it is a great asset since we already support closures and lambdas.
{code}
lazy var temp = calculate( 43 );
var num = 4;
if( num > 5 && temp > 5 ){
}
{code}
From the example above the num > 5 will short circuit the if statement, but the temp variable will be eagerly evaluated by the language even though it is not needed. Therefore, introducing the lazy keyword we can delay the evaluation of the variable until it is needed imperatively.
Resource: https://blog.codecentric.de/en/2016/02/lazy-vals-scala-look-hood/
Attachments:
Comments: