Search code examples
dkeywordstorage-class-specifier

What are pure variables?


I was surprised to find that this code compiles:

pure string Foo = SomePureFunction(123);

pure is only mentioned in the context of functions in the online documentation.

What are pure variables, and how are they different from immutable and const ones?


Solution

  • The attribute just has no effect in this case. It's a known issue in DMD, there are quite a number other similar cases, where attributes are not rejected, but don't have any effect as well.