digitalmars.D.announce - DMD 1.025 and 2.009 releases
- Walter Bright (5/5) Jan 01 2008 New const/invariant/enum in 2.009!
- John Reimer (5/12) Jan 01 2008 Ah ha! A new year surprise!
- Don Clugston (4/11) Jan 01 2008 Nice CTFE fixes, too. Thanks, Walter.
- Marcin Kuszczak (42/49) Jan 01 2008 There is something wrong with linux libphobos2 library.
- Walter Bright (2/3) Jan 01 2008 I just uploaded it again. I think I inadvertently posted the old one.
- Aarti_pl (8/12) Jan 02 2008 Great! Now it works perfectly.
- =?UTF-8?B?IuOBruOBl+OBhOOBiyAobm9zaGlpa2EpIg==?= (20/27) Jan 01 2008 Happy new year, Walter!
- Walter Bright (4/6) Jan 01 2008 with:
- Jarrett Billingsley (8/14) Jan 01 2008 Solve:
- =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= (22/43) Jan 01 2008 -----BEGIN PGP SIGNED MESSAGE-----
- Jarrett Billingsley (3/10) Jan 01 2008 I'm crying.
- =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= (17/31) Jan 01 2008 -----BEGIN PGP SIGNED MESSAGE-----
- Jarrett Billingsley (6/7) Jan 01 2008 OK. I guess the point I was trying to make before is that you can't
- Charles D Hixson (9/20) Jan 01 2008 General solution? (untested)
- Charles D Hixson (4/24) Jan 02 2008 I just re-checked the documentation, and it doesn't say that
- Walter Bright (7/15) Jan 01 2008 C cx;
- Jarrett Billingsley (3/9) Jan 01 2008 ...
- Walter Bright (9/20) Jan 01 2008 Note that this isn't any different from what you'd write for a const int...
- Bill Baxter (15/36) Jan 01 2008 It's also the same sort of rigmarole you have to go through to
- Daniel919 (17/23) Jan 01 2008 Wouldn't it be good if there was a way to express
- BCS (7/28) Jan 01 2008 const(C) c =
- =?UTF-8?B?IuOBruOBl+OBhOOBiyAobm9zaGlpa2EpIg==?= (3/13) Jan 02 2008 Oh, then, I have to declare a variable each time I want to assign a new
- Walter Bright (5/19) Jan 02 2008 Right. Just as if C were an int:
- Jason House (5/12) Jan 01 2008 Has the const/invariant/enum documentation been updated yet?
- Walter Bright (2/7) Jan 01 2008 See http://www.digitalmars.com/d/enum.html for the enum stuff.
- Jason House (16/25) Jan 01 2008 ... so you're saying that I can define manifest constants in several
- John Reimer (28/50) Jan 01 2008 Yes, I saw that too. I'm guessing that Walter was saying here that an
- Jason House (2/18) Jan 02 2008 That's really my whole point. There's plenty of room for confusion and ...
- Pablo Ripolles (4/11) Jan 02 2008 Hello and Happy New Year!
- Walter Bright (1/1) Jan 02 2008 Fixed.
- Robert DaSilva (5/12) Jan 02 2008 Finally, I can try to break it. It was no fun too break something that
- eao197 (42/43) Jan 12 2008 I have tried this sample:
- torhu (7/24) Jan 12 2008 void show( in Message m )
- naryl (5/27) Jan 12 2008 But what 'new invariant(Message)' is supposed to do? I can't find it in ...
- torhu (3/5) Jan 12 2008 As far as I know, it doesn't do anything. DMD allows some syntaxes that...
- Walter Bright (2/3) Jan 13 2008 It is, and it's a compiler bug that will get fixed.
- baaaam (3/10) Jan 13 2008 1) is there any up to date documentation for the way const/invariant/enu...
- Walter Bright (3/8) Jan 13 2008 private enum i = 3;
- baaaam (9/20) Jan 13 2008 so did anything change in the behaviour of const/invaraiant ?
- Moritz Warning (5/16) Jan 13 2008 private members are always accessible on the same module level.
- baaaam (2/20) Jan 13 2008 right, thats exactly what i did and i was able to access that private me...
- foobar (10/17) Jan 13 2008 nice work !
- Vladimir Panteleev (9/18) Jan 13 2008 ng the const/invariant stuff. what has changed in the behaviour of const...
- foobar (2/19) Jan 13 2008 i am very sorry but i am not native in english and i really dont know wh...
New const/invariant/enum in 2.009! http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.025.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.009.zip
Jan 01 2008
Walter Bright wrote:New const/invariant/enum in 2.009! http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.025.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.009.zipAh ha! A new year surprise! Happy new year, Walter. (you are in the same time zone as me). -JJR
Jan 01 2008
Walter Bright wrote:New const/invariant/enum in 2.009! http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.025.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.009.zipNice CTFE fixes, too. Thanks, Walter. Happy New Year! Don.
Jan 01 2008
Walter Bright wrote:New const/invariant/enum in 2.009! http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.025.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.009.zipThere is something wrong with linux libphobos2 library. I get linker errors for simplest program: -------------- import std.stdio; void main() { writefln("Just a test!"); } ------------- Version 2.008 works just right. marcin genesis:~/Programy/D/TestCases/src$ dmd quicktest.d gcc quicktest.o -o quicktest -m32 -Xlinker -L/usr/local/lib -lphobos2 -lpthread -lm quicktest.o: In function `_D3std8bitmanip102__T15createAccessorsVAyaa20_6672616374696f6e6578706f6e656e747369676eTkVyG8aa8_6672616374696f6eVi23Vk0Z15createAccessorsFZAya': quicktest.d (.text._D3std8bitmanip102__T15createAccessorsVAyaa20_6672616374696f6e6578706f6e656e747369676eTkVyG8aa8_6672616374696f6eVi23Vk0Z15createAccessorsFZAya+0x27): undefined reference to `_D3std8bitmanip11toStringSfxFmZAya' quicktest.d (.text._D3std8bitmanip102__T15createAccessorsVAyaa20_6672616374696f6e6578706f6e656e747369676eTkVyG8aa8_6672616374696f6eVi23Vk0Z15createAccessorsFZAya+0x41): undefined reference to `_D3std8bitmanip11toStringSfxFmZAya' quicktest.d (.text._D3std8bitmanip102__T15createAccessorsVAyaa20_6672616374696f6e6578706f6e656e747369676eTkVyG8aa8_6672616374696f6eVi23Vk0Z15createAccessorsFZAya+0xa3): undefined reference to `_D3std8bitmanip11toStringSfxFmZAya' quicktest.d (.text._D3std8bitmanip102__T15createAccessorsVAyaa20_6672616374696f6e6578706f6e656e747369676eTkVyG8aa8_6672616374696f6eVi23Vk0Z15createAccessorsFZAya+0xba): undefined reference to `_D3std8bitmanip11toStringSfxFmZAya' quicktest.d (.text._D3std8bitmanip102__T15createAccessorsVAyaa20_6672616374696f6e6578706f6e656e747369676eTkVyG8aa8_6672616374696f6eVi23Vk0Z15createAccessorsFZAya+0xf8): undefined reference to `_D3std8bitmanip11toStringSfxFmZAya' quicktest.o:quicktest.d (.text._D3std8bitmanip102__T15createAccessorsVAyaa20_6672616374696f6e6578706f6e656e747369676eThVyG8aa8_6578706f6e656e74Vi8Vk23Z15createAccessorsFZAya+0x27): more undefined references to `_D3std8bitmanip11toStringSfxFmZAya' follow collect2: ld returned 1 exit status --- errorlevel 1 -- Regards Marcin Kuszczak (Aarti_pl) ------------------------------------- Ask me why I believe in Jesus - http://www.zapytajmnie.com (en/pl) Doost (port of few Boost libraries) - http://www.dsource.org/projects/doost/ -------------------------------------
Jan 01 2008
Marcin Kuszczak wrote:There is something wrong with linux libphobos2 library.I just uploaded it again. I think I inadvertently posted the old one.
Jan 01 2008
Walter Bright pisze:Marcin Kuszczak wrote:Great! Now it works perfectly. BTW. Thanks for nice release. Personally I like new enum design. The old, traditional enum was too limited, and IMHO there was a great need for something better. BR Marcin Kuszczak (aarti_pl)There is something wrong with linux libphobos2 library.I just uploaded it again. I think I inadvertently posted the old one.
Jan 02 2008
Walter Bright wrote:New const/invariant/enum in 2.009! http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.025.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.009.zipHappy new year, Walter! This update caused a massive breakage to my program and I don't have any idea how to observe the new const/invariant rules. Codes using const class or struct are broken: -------------------------------------------- import std.conv, std.stdio; class C { private int i; this(int i) { this.i = i; } const string toString() { return to!(string)(this.i); } } void main() { const(C) c; c = new C(1); // error writeln(c); } -------------------------------------------- Please help me upgrade to 2.009! Thank you.
Jan 01 2008
のしいか (noshiika) wrote: Replace:const(C) c; c = new C(1); // errorwith: const(C) c = new C(1);
Jan 01 2008
"Walter Bright" <newshound1 digitalmars.com> wrote in message news:fle8mi$1j24$2 digitalmars.com...???? (noshiika) wrote: Replace:Solve: const(C) c; if(someCondition) c = new C(1); else c = new C(2);const(C) c; c = new C(1); // errorwith: const(C) c = new C(1);
Jan 01 2008
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jarrett Billingsley wrote:"Walter Bright" <newshound1 digitalmars.com> wrote in message news:fle8mi$1j24$2 digitalmars.com...Untested: const(C) c = (delegate const(C) () { if (someCondition) return new C(1); else return new C(2); })(); Jerome - -- +------------------------- Jerome M. BERGER ---------------------+ | mailto:jeberger free.fr | ICQ: 238062172 | | http://jeberger.free.fr/ | Jabber: jeberger jabber.fr | +---------------------------------+------------------------------+ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFHeqxwd0kWM4JG3k8RAmbAAKCogrgIIj0/6oNi4WfoM5PkLcPawgCgjvR6 5kpZYty6ulyuKkbKSUXTeto= =TqPW -----END PGP SIGNATURE-----???? (noshiika) wrote: Replace:Solve: const(C) c; if(someCondition) c = new C(1); else c = new C(2);const(C) c; c = new C(1); // errorwith: const(C) c = new C(1);
Jan 01 2008
""Jrme M. Berger"" <jeberger free.fr> wrote in message news:flea9n$1n0r$1 digitalmars.com...Untested: const(C) c = (delegate const(C) () { if (someCondition) return new C(1); else return new C(2); })();I'm crying.
Jan 01 2008
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jarrett Billingsley wrote:""J�r�me M. Berger"" <jeberger free.fr> wrote in message news:flea9n$1n0r$1 digitalmars.com...In fact, there's much simpler: const (C) c = (someCondition) ? (new C (1)) : (new C (2)), Jerome - -- +------------------------- Jerome M. BERGER ---------------------+ | mailto:jeberger free.fr | ICQ: 238062172 | | http://jeberger.free.fr/ | Jabber: jeberger jabber.fr | +---------------------------------+------------------------------+ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFHeq9rd0kWM4JG3k8RAkXZAJ4+/gomgWy6HvcMZ85Kt3Y6y4f2EACgrEQs lslXsrsfZwRjeLlqvj2i7Ng= =HFSY -----END PGP SIGNATURE-----Untested: const(C) c = (delegate const(C) () { if (someCondition) return new C(1); else return new C(2); })();I'm crying.
Jan 01 2008
""Jrme M. Berger"" <jeberger free.fr> wrote in message news:fleb1b$1ol5$1 digitalmars.com...const (C) c = (someCondition) ? (new C (1)) : (new C (2)),OK. I guess the point I was trying to make before is that you can't generally combine declaration and initialization. I'm sure you can all imagine a more complex example that would be prohibitive/stupid to try to initialize in a single expression.
Jan 01 2008
Jarrett Billingsley wrote:""Jrme M. Berger"" <jeberger free.fr> wrote in message news:fleb1b$1ol5$1 digitalmars.com...General solution? (untested) 1) define a function to return a value of the desired type and value. 2) use it to assign a value to a constant. I suspect that this function might need to be static, but I seem to remember that const is intentionally limited to rom-able values, so that shouldn't be too restrictive. It's still not as pleasant as being able to assign once.const (C) c = (someCondition) ? (new C (1)) : (new C (2)),OK. I guess the point I was trying to make before is that you can't generally combine declaration and initialization. I'm sure you can all imagine a more complex example that would be prohibitive/stupid to try to initialize in a single expression.
Jan 01 2008
Charles D Hixson wrote:Jarrett Billingsley wrote:I just re-checked the documentation, and it doesn't say that it can't be changed after compile time at all...in fact it says that it *CAN* be changed, just not via the const reference.""Jrme M. Berger"" <jeberger free.fr> wrote in message news:fleb1b$1ol5$1 digitalmars.com...General solution? (untested) 1) define a function to return a value of the desired type and value. 2) use it to assign a value to a constant. I suspect that this function might need to be static, but I seem to remember that const is intentionally limited to rom-able values, so that shouldn't be too restrictive. It's still not as pleasant as being able to assign once.const (C) c = (someCondition) ? (new C (1)) : (new C (2)),OK. I guess the point I was trying to make before is that you can't generally combine declaration and initialization. I'm sure you can all imagine a more complex example that would be prohibitive/stupid to try to initialize in a single expression.
Jan 02 2008
Jarrett Billingsley wrote:Solve: const(C) c; if(someCondition) c = new C(1); else c = new C(2);C cx; if (someCondition) cx = new C(1); else cx = new C(2); const(C) c = cx;
Jan 01 2008
"Walter Bright" <newshound1 digitalmars.com> wrote in message news:flebgf$1pmb$1 digitalmars.com...C cx; if (someCondition) cx = new C(1); else cx = new C(2); const(C) c = cx;...
Jan 01 2008
Jarrett Billingsley wrote:"Walter Bright" <newshound1 digitalmars.com> wrote in message news:flebgf$1pmb$1 digitalmars.com...Note that this isn't any different from what you'd write for a const int: int ix; if (someCondition) ix = 1; else ix = 2; const(int) i = ix; or const of any type.C cx; if (someCondition) cx = new C(1); else cx = new C(2); const(C) c = cx;...
Jan 01 2008
Walter Bright wrote:Jarrett Billingsley wrote:It's also the same sort of rigmarole you have to go through to conditionally initialize a reference in C++ since they cannot be rebound except at initialization. C++ programmers manage to get by with that. But that still doesn't mean it's the ideal way to do such initializations. In particular it looks pretty inefficient if we're talking about a BigStruct instead of an int. (I'd probably just switch to using a const pointer to refer to the BigStruct under the current rules.) At any rate, the lack of this capability doesn't seem a big enough problem to justify scrapping the new const. Or even to try "fixing" it with new syntax so soon before we've had the chance to get used to the new system. If the above does turn out to be a big deal in practice, perhaps some new initializer syntax could be added to make that sort of thing easier, but it doesn't look like a deal-breaker either way. --bb"Walter Bright" <newshound1 digitalmars.com> wrote in message news:flebgf$1pmb$1 digitalmars.com...Note that this isn't any different from what you'd write for a const int: int ix; if (someCondition) ix = 1; else ix = 2; const(int) i = ix; or const of any type.C cx; if (someCondition) cx = new C(1); else cx = new C(2); const(C) c = cx;...
Jan 01 2008
C cx; if (someCondition) cx = new C(1); else cx = new C(2); const(C) c = cx;Wouldn't it be good if there was a way to express "I will not modify this anymore", instead of creating a new object? C c; if (someCondition) c = new C(1); else c = new C(2); cast(invariant) c; //from now on, c will not change anymore //more code ... The last line could do sth like: { //new scope invariant c = cast(invariant) c; //shadowing declaration //more code ... } //ends just before the ... } //... end of the outer scope Best regards, Daniel
Jan 01 2008
Reply to Jarrett,"Walter Bright" <newshound1 digitalmars.com> wrote in message news:fle8mi$1j24$2 digitalmars.com...const(C) c = (someCondition) ? new C(1) : new C(2); or: const(C) c = new C((someCondition) ? 1 : 2);???? (noshiika) wrote: Replace:Solve: const(C) c; if(someCondition) c = new C(1); else c = new C(2);const(C) c; c = new C(1); // errorwith: const(C) c = new C(1);
Jan 01 2008
Walter Bright wrote:のしいか (noshiika) wrote: Replace:Oh, then, I have to declare a variable each time I want to assign a new value of const(class) object or a generic type, now...const(C) c; c = new C(1); // errorwith: const(C) c = new C(1);
Jan 02 2008
のしいか (noshiika) wrote:Walter Bright wrote:Right. Just as if C were an int: const(int) i; i = 3; // error const(int) i = 3; // okのしいか (noshiika) wrote: Replace:Oh, then, I have to declare a variable each time I want to assign a new value of const(class) object or a generic type, now...const(C) c; c = new C(1); // errorwith: const(C) c = new C(1);
Jan 02 2008
Walter Bright wrote:New const/invariant/enum in 2.009! http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.025.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.009.zipHas the const/invariant/enum documentation been updated yet? Looking at http://www.digitalmars.com/d/const3.html, there is no mention of enum. It does discuss manifest constants... Can you please update the docs to reflect the new design?
Jan 01 2008
Jason House wrote:Has the const/invariant/enum documentation been updated yet? Looking at http://www.digitalmars.com/d/const3.html, there is no mention of enum. It does discuss manifest constants... Can you please update the docs to reflect the new design?See http://www.digitalmars.com/d/enum.html for the enum stuff.
Jan 01 2008
Walter Bright wrote:Jason House wrote:... so you're saying that I can define manifest constants in several different ways? Quoting the online docs: "The simplest invariant declarations use it as a storage class. It can be used to declare manifest constants. invariant int x = 3; // x is set to 3" I thought manifest constants were going to be made more explicit. That way, it's known when taking an address of something is valid. Afterall, the docs also say: "Invariant used as a storage class is equivalent to using invariant as a type constructor for the entire type of a declaration: invariant int x = 3; // x is typed as invariant(int) invariant(int) y = 3; // y is invariant" ... after all the discussion about const/invariant/manifest, I think the docs should be very clear on this topic. I don't want to see more long threads about manifest constants.Has the const/invariant/enum documentation been updated yet? Looking at http://www.digitalmars.com/d/const3.html, there is no mention of enum. It does discuss manifest constants... Can you please update the docs to reflect the new design?See http://www.digitalmars.com/d/enum.html for the enum stuff.
Jan 01 2008
Jason House wrote:Walter Bright wrote:Yes, I saw that too. I'm guessing that Walter was saying here that an invariant /also/ can be used as a sort of manifest constant declaration. .. not of the formal sort like that of the "anonymous enum"; but people might like to take advantage of the invariants immutability for such a purpose... and so the same with "const". I wager these are the 4 ways to do manifests that Walter was referring to in earlier posts: invariant, const, named enum, and anonymous enum - the last being the "true" manifest constant. That's why he felt he shouldn't have to add another keyword to replace the anonymous enum version if he could just stretch enum a bit more at the seams. (incidentally, notice that the four ways still exist). But are these four ways equivalent and the link level? I don't think so. My question is whether this "type" of manifest constant takes up any symbol space in the program...you know: the way the libraries used to get bloated with D's old constants (something that seemed to circumvented with anonymous enums). Do all these consts (when used like manifests) truly mirror the weightless "#define". I think only the "enum" version does...unless the compiler is indeed smart enough here. But yes, the docs do tend to mix things up a little. Probably best to avoid referring to manifest constants in the discussion on immutables in that context. Other than that, I was surprised that I actually seemed to be able to grasp the const/invariant section this time around. It is fairly understandable and simply presented. Perhaps the complexities and problems will show up in actual practice, but for now the explanations seemed well done. -JJRJason House wrote:... so you're saying that I can define manifest constants in several different ways? Quoting the online docs: "The simplest invariant declarations use it as a storage class. It can be used to declare manifest constants. invariant int x = 3; // x is set to 3" I thought manifest constants were going to be made more explicit. That way, it's known when taking an address of something is valid. Afterall, the docs also say:Has the const/invariant/enum documentation been updated yet? Looking at http://www.digitalmars.com/d/const3.html, there is no mention of enum. It does discuss manifest constants... Can you please update the docs to reflect the new design?See http://www.digitalmars.com/d/enum.html for the enum stuff.
Jan 01 2008
John Reimer Wrote:I wager these are the 4 ways to do manifests that Walter was referring to in earlier posts: invariant, const, named enum, and anonymous enum - the last being the "true" manifest constant. That's why he felt he shouldn't have to add another keyword to replace the anonymous enum version if he could just stretch enum a bit more at the seams. (incidentally, notice that the four ways still exist). But are these four ways equivalent and the link level? I don't think so. My question is whether this "type" of manifest constant takes up any symbol space in the program...you know: the way the libraries used to get bloated with D's old constants (something that seemed to circumvented with anonymous enums). Do all these consts (when used like manifests) truly mirror the weightless "#define". I think only the "enum" version does...unless the compiler is indeed smart enough here. But yes, the docs do tend to mix things up a little.That's really my whole point. There's plenty of room for confusion and assumptions when reading the docs. I feel like I keep posting stuff like "please add this to the docs", or "please clarify this in the docs". Being a developer, I understand the pain of documentation, but it truly is important... especially for D when there's lots of people (like me) who refuse to use D 2.x until they're convinced the design is both sane and stable. Actually, I might hold off on porting my code until the Tango + Phobos merger is (nearly?) complete.
Jan 02 2008
Walter Bright Wrote:New const/invariant/enum in 2.009! http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.025.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.009.zipHello and Happy New Year! The example in the D Programming Language 2.0 root web page (http://www.digitalmars.com/d/) doesn't compile with dmd.2.008, I haven't been able to try it with the last version though. This is one of those things whose update may be missed easily. Exactly this same example was the first compilation I tried with the dmd compiler and I think it should welcome new developers. Cheers!
Jan 02 2008
Walter Bright wrote:New const/invariant/enum in 2.009! http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.025.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.009.zipFinally, I can try to break it. It was no fun too break something that was already thrown out ( http://www.digitalmars.com/d/archives/digitalmars/D/Invariants_broken_with_out_cast_63199.html ).
Jan 02 2008
On Tue, 01 Jan 2008 12:37:38 +0300, Walter Bright = <newshound1 digitalmars.com> wrote:New const/invariant/enum in 2.009!I have tried this sample: import std.stdio; class Notifier { int i; this( int i_value ) { i =3D i_value; } } class Message { public Notifier notifier; this( Notifier notifier_object ) { notifier =3D notifier_object; } } void main() { void show( Message m ) { writefln( &m.notifier, ": ", m.notifier.i ); } auto m1 =3D new Message( new Notifier( 1 ) ); show( m1 ); auto m2 =3D new invariant(Message)( new Notifier( 2 ) ); show( m2 ); m2.notifier =3D new Notifier( 3 ); show( m2 ); } and got: 882FF8: 1 882FD8: 2 882FD8: 3 Why m2 is not an invariant object? -- = Regards, Yauheni Akhotnikau
Jan 12 2008
eao197 wrote: I've modified 3 lines in your main function:void main() { void show( Message m )void show( in Message m ){ writefln( &m.notifier, ": ", m.notifier.i );writefln( cast(Notifier*)&m.notifier, ": ", m.notifier.i );} auto m1 = new Message( new Notifier( 1 ) ); show( m1 ); auto m2 = new invariant(Message)( new Notifier( 2 ) );auto m2 = cast(invariant) new Message( new Notifier( 2 ) );show( m2 ); m2.notifier = new Notifier( 3 ); show( m2 ); }With these changes, I get the error "Error: cannot modify const/invariant m2.notifier".
Jan 12 2008
On Sat, 12 Jan 2008 23:26:58 +0300, torhu <no spam.invalid> wrote:eao197 wrote: I've modified 3 lines in your main function:;void main() { void show( Message m )void show( in Message m ){ writefln( &m.notifier, ": ", m.notifier.i );writefln( cast(Notifier*)&m.notifier, ": ", m.notifier.i )=} auto m1 =3D new Message( new Notifier( 1 ) ); show( m1 ); auto m2 =3D new invariant(Message)( new Notifier( 2 ) );auto m2 =3D cast(invariant) new Message( new Notifier( 2 ) );show( m2 ); m2.notifier =3D new Notifier( 3 ); show( m2 ); }With these changes, I get the error "Error: cannot modify =const/invariant m2.notifier".But what 'new invariant(Message)' is supposed to do? I can't find it in = = the docs.
Jan 12 2008
naryl wrote:But what 'new invariant(Message)' is supposed to do? I can't find it in the docs.As far as I know, it doesn't do anything. DMD allows some syntaxes that have no effect. It's a bit confusing sometimes.
Jan 12 2008
eao197 wrote:Why m2 is not an invariant object?It is, and it's a compiler bug that will get fixed.
Jan 13 2008
1) is there any up to date documentation for the way const/invariant/enum works now ? 2) whats the use for the enum manifest stuff since it renders it even impossible to apply visibility attributes to const of that style. enum manifest consts are always "static public" as it seems.. Walter Bright Wrote:New const/invariant/enum in 2.009! http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.025.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.009.zip
Jan 13 2008
baaaam wrote:1) is there any up to date documentation for the way const/invariant/enum works now ?Yes, click the links on "enum" and "const" on the documentation pages.2) whats the use for the enum manifest stuff since it renders it even impossible to apply visibility attributes to const of that style. enum manifest consts are always "static public" as it seems..private enum i = 3;
Jan 13 2008
Walter Bright Wrote:baaaam wrote:so did anything change in the behaviour of const/invaraiant ? "Both invariant and const are transitive, .." -> i thought this is not the case ? wasnt there too many problems with it ? i am confused and i guess i am not the only one.1) is there any up to date documentation for the way const/invariant/enum works now ?Yes, click the links on "enum" and "const" on the documentation pages.this doesnt prevent anything from accessing that value of i. I testet it with dmd 2.009. struct Foo{ private enum i = 3; } every other piece of code can access i through "Foo.i" .2) whats the use for the enum manifest stuff since it renders it even impossible to apply visibility attributes to const of that style. enum manifest consts are always "static public" as it seems..private enum i = 3;
Jan 13 2008
On Sun, 13 Jan 2008 06:17:25 -0500, baaaam wrote:"Both invariant and const are transitive, .." -> i thought this is not the case ? wasnt there too many problems with it ? i am confused and i guess i am not the only one."Both invariant and const are transitive, .." - that's right (for D2.00x).this doesnt prevent anything from accessing that value of i. I testet it with dmd 2.009. struct Foo{ private enum i = 3; } every other piece of code can access i through "Foo.i" .private members are always accessible on the same module level. If you have two modules (= two files), they can't access each others private members.
Jan 13 2008
Moritz Warning Wrote:On Sun, 13 Jan 2008 06:17:25 -0500, baaaam wrote:right, thats exactly what i did and i was able to access that private member from another module. thats why i wondered, sounds like a bug huh ?"Both invariant and const are transitive, .." -> i thought this is not the case ? wasnt there too many problems with it ? i am confused and i guess i am not the only one."Both invariant and const are transitive, .." - that's right (for D2.00x).this doesnt prevent anything from accessing that value of i. I testet it with dmd 2.009. struct Foo{ private enum i = 3; } every other piece of code can access i through "Foo.i" .private members are always accessible on the same module level. If you have two modules (= two files), they can't access each others private members.
Jan 13 2008
nice work ! i am very curious what exactly has changed from 2.008 to 2.009 regarding the const/invariant stuff. what has changed in the behaviour of const and why is there enum as another way to manifest a constant ? where is the difference between invariant int x = 3; or const int x = 3; and enum int x = 3; ? Walter Bright Wrote:New const/invariant/enum in 2.009! http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.025.zip http://www.digitalmars.com/d/changelog.html http://ftp.digitalmars.com/dmd.2.009.zip
Jan 13 2008
On Sun, 13 Jan 2008 21:47:36 +0200, foobar <foobar nomail.net> wrote:nice work ! i am very curious what exactly has changed from 2.008 to 2.009 regardi=ng the const/invariant stuff. what has changed in the behaviour of const= and why is there enum as another way to manifest a constant ?where is the difference between invariant int x =3D 3; or const int x =3D 3; and enum int x =3D 3; ?Out of those three, here is only one way to declare a manifest constant = - enum. The first two will take up space in the resulting binary. Also, sock puppetry is not nice (if you did that on purpose). -- = Best regards, Vladimir mailto:thecybershadow gmail.com
Jan 13 2008
Vladimir Panteleev Wrote:On Sun, 13 Jan 2008 21:47:36 +0200, foobar <foobar nomail.net> wrote:i am very sorry but i am not native in english and i really dont know what sock puppetry is. can explain that ?nice work ! i am very curious what exactly has changed from 2.008 to 2.009 regarding the const/invariant stuff. what has changed in the behaviour of const and why is there enum as another way to manifest a constant ? where is the difference between invariant int x = 3; or const int x = 3; and enum int x = 3; ?Out of those three, here is only one way to declare a manifest constant - enum. The first two will take up space in the resulting binary. Also, sock puppetry is not nice (if you did that on purpose).
Jan 13 2008