[Issue 7381] Make auto tail-const

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 27 15:37:16 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7381



--- Comment #2 from Jonathan M Davis <jmdavisProg at gmx.com> 2012-01-27 15:37:11 PST ---
Presumably, it would either use the generic type explicitly or use typeof. And
if it really wanted const, then it could just use const explicitly.

If the dropping of constness would make the assignment not possible though, I
would argue that the constness should be kept. So, then as long as the code
isn't in a situation where it doesn't need to keep constness but it _wants_ to,
auto works great. Whereas now, it's really easy to get into a situation where
you end up with a const or immutable variable when you really didn't want one,
just because the template was instatiated with a const or immutable type.

In general though, I think that if you want const or immutable, you use const
or immutable rather than auto. So, the fact that auto preserves full constness
causes far more problems than it would if it just preserved tail-constness.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list