DMD 1.011 release -- prior code does not compile

Walter Bright newshound1 at digitalmars.com
Wed Apr 11 13:02:24 PDT 2007


kris wrote:
> Walter Bright wrote:
>> Bug fixes, some enhancements.
>>
>> http://www.digitalmars.com/d/changelog.html
>>
>> http://ftp.digitalmars.com/dmd.1.011.zip
> 
> 
> ----
> struct HttpStatus
> {
>         int     code;
>         char[]  name;
> }
> 
> struct HttpResponses
> {
>         final HttpStatus Continue = {100, "Continue"};
> }
> 
> void foo (inout HttpStatus status)
> {
> }
> 
> void main ()
> {
>         foo (HttpResponses.Continue);
> }
> ---
> 
> "Error: cannot modify final variable 'Continue'"
> 
> The above used to compile. How is one supposed to declare and populate a 
> struct that cannot subsequently be changed, and can also be passed by 
> reference?

In the future, inout would be replaced with "const ref".


> (if you change 'final' to 'const' within the HttpResponses struct, the 
> same error is generated, and saying "final" rather than "const")
> 



More information about the Digitalmars-d-announce mailing list