Feature request: supplement by-name parameter syntax with "lazy" keyword

This just reminds me that ‘lazy val’ is a bad name and leads to poor assumptions about how best to use it. A better name would have been ‘memoize def’.

After all, that is what it is. It behaves like a def more than a val in many critical ways (especially w.r.t. initialization and inheritance).

I frequently need to teach beginners this, telling them not to think of it as a val at all.

The lazy prefix is only applicable in contexts where val can be replaced with def… because its truly a def at heart.

1 Like