Is there any benefit in explicitly freezing variables? As a simple example, see the following snippets:
The variable x
is initialized and then used to compute something else. In one, x
is mutable throughout the program. In the other, x
is frozen after it's initialized.
The LLVM appears to be slightly different, which makes me believe there might be some benefit for more complex programs. However, I'm no LLVM expert.
Of course, there are obvious benefits about conveying the developer's intent and using the type system to prevent bugs. On the other hand, there's also more complexity in this pattern, particularly if we're doing this for several bindings in the same block. I'm wondering if there's a performance benefit--now or in the future--that might make this definitely worth it.