DMD 1.011 release -- prior code does not compile

kris foo at bar.com
Wed Apr 11 12:54:19 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?
> 
> (if you change 'final' to 'const' within the HttpResponses struct, the 
> same error is generated, and saying "final" rather than "const")
> 


In a similar fashion, this kinda' thing used to work just fine:

---
struct Foo
{
	final char[] x;
}

static Foo foo = {"something"};
---

"Error: too many initializers"

How is one now supposed to declare struct contents that are immutable 
after being set to an initial value?



More information about the Digitalmars-d-announce mailing list