Metaprogramming and Compile-Time

If the REPL can’t make it visible, doesn’t it mean there isn’t a semantic difference? As types aren’t mutable, the only thing I can think of where laziness would make a semantic difference is infinite recursion, which the compiler doesn’t seem to allow on the type level (results in “illegal cyclic reference”). I don’t think the language specification says anything about compile-time performance (at least for 2.13, couldn’t find the spec for 3.0).

1 Like

No it doesn’t. But, anyway, that semantic difference is indeed what I am looking for.

You’re ignoring a number of decades’ research on Programming Languages there, I’m afraid. Haskell and Idris are both pure. Haskell is lazy but Idris is strict (both by default, albeit).

The matter of performance is only of a secondary interest to me. It’s the operational nature that I am after now.

I think “semantic” was probably the wrong term to use. I meant, are there cases where the resulting runtime code would produce different results, depending on the compile time type reduction being lazy or strict? I’d be interested to learn about such cases.

I think the section of interest here for Scala 2.13 is Type Declarations and Type Aliases. In particular, this section says that certain declarations and definitions are illegal by themselves independent of usage, which implies greedy evaluation.

1 Like