What are pure variables?
Asked Answered
M

1

9

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?

Malamute answered 3/2, 2012 at 21:14 Comment(0)
L
6

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.

Lentigo answered 3/2, 2012 at 21:22 Comment(4)
Could you cite a bug report or mailing list discussion?Malamute
I can confirm this (though also not cite a bug).Gluteal
This is a related bug report, but if there are other reports, they're probably for specific instances of the issue. It should be noted, however, that in many cases, Walter Bright doesn't consider ignored attributes to be a bug (though he does in some instances). Also, in some cases, being strict about it would cause issues for generic code. So, whether it's fixed or not is likely to be determined on a case by case basis.Andres
I've created a bug report for this specific issue. It may or may not end up being marked as a duplicate, but at least this specific instance of invalid attributes being ignored has now been flagged.Andres

© 2022 - 2024 — McMap. All rights reserved.