You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.
Elara Enhancement Proposal
Why does this Proposal exist?
Laziness is a key part of functional programming. Take Haskell for example: everything is lazy - no expression is evaluated until actually necessary.
Some languages implement this as part of their standard library - eg Kotlin or Rust (I think), however this proposal targets the language level.
What does this proposal not change?
What does this Proposal suggest?
The proposal suggests a new keyword:
lazy
The lazy keyword is applicable to:
It should be placed before
mut
, and before the type in a parameter.For example:
What does this keyword do?
The lazy keyword delays the evaluation of a given expression until the identifier associated with that expression is referenced.
For example:
If
some-bool
evaluates to false,other.something()
is never evaluated as the function has already stopped execution.In another example:
The output of this program (assuming
condition
to be true) isBecause the value of
error-msg
is not evaluated until it's actually referenced.What does this Proposal achieve?
This primarily allows for some powerful optimisations in functions:
Laziness is also a useful tool for day to day programming, but again a language level feature seems more flexible than
Lazy<T>
orby lazy {}
The text was updated successfully, but these errors were encountered: