[Issue 7724] 'final:' causes error if any variable declarations are placed between it and the end of its scope

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 24 11:52:49 PDT 2012


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


Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com
           Severity|critical                    |enhancement


--- Comment #15 from Walter Bright <bugzilla at digitalmars.com> 2012-04-24 11:53:49 PDT ---
The compiler behavior here is obviously deliberate, so this isn't a bug but an
enhancement request.

'final' in Java for a variable means it is assigned once in the constructor,
and never again. The equivalent is achieved in D using 'const' and not
supplying an initializer.

'final' in D1 has similar semantics to Java.

The reason 'final' applied to fields in D2 is an error is so that the user
transferring code from D1 to D2 will be notified of changes required, rather
than silently breaking his code.

Silently breaking code is very, very bad. There are still a lot of D users who
are moving from D1 to D2, and while that's going on I don't think implementing
this is a good idea.

-- 
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