digitalmars.D - Ana Kedi
- Salih Dincer (45/45) Aug 12 2022 Hi, what do you think should have been in lieu of runtime error?
- frame (5/6) Aug 13 2022 This seems to address some bugs? Except #1, it happily crashes
- Ivan Kazmenko (27/29) Aug 15 2022 Related: there is a version statement, resembling `{$ifdef}` in
- bauss (2/32) Aug 15 2022 debug creates a new scope.
- Ivan Kazmenko (9/15) Aug 16 2022 Hmm, on the contrary, this works for me (dmd 2.0.100):
- Adam D Ruppe (2/3) Aug 16 2022 debug and version work exactly the same way. there's no new scope.
Hi, what do you think should have been in lieu of runtime error? Thanks, ```d /* No compile error for v2 & v3 * * Runtime Error: * Segmentation fault (core dumped) * * Compiler: * rdmd playground.d */ struct Ana { char a; // Kedi k; // assertions complated union { char b; char p; } union Kedi { char cat; char edi; } } Ana ana = { 97, k : Ana.Kedi(107), 98 }; // ana.writeln(", ", ana.k.edi); with(ana) { assert(b == 'b'); // 'b' == 98 assert(b == p); // p == 'b' assert(k.cat == 'k'); // 'k' == 107 assert(k.cat == k.edi); // k.edi == 'k' } ``` SDB 79
Aug 12 2022
On Friday, 12 August 2022 at 23:04:50 UTC, Salih Dincer wrote:Hi, what do you think should have been in lieu of runtime error?DMD on Windows, LDC refuses to compile with "too many initializers for `Ana`", both are good with explicit member initializers.
Aug 13 2022
On Friday, 12 August 2022 at 23:04:50 UTC, Salih Dincer wrote:Hi, what do you think should have been in lieu of runtime error? ...Related: there is a version statement, resembling `{$ifdef}` in Pascal or `#ifdef` in C, but arguably cleaner. Consider this: ``` struct Ana { char a; version (v1) {Kedi k;} // assertions complated union { char b; char p; } union Kedi { char cat; char edi; } } ``` Then compile with `dmd -version v3` or the like. Note that the `{}` for compile-time features (such as `version`, `debug` or `static if`) don't introduce a new scope. Ivan Kazmenko.
Aug 15 2022
On Monday, 15 August 2022 at 16:34:29 UTC, Ivan Kazmenko wrote:On Friday, 12 August 2022 at 23:04:50 UTC, Salih Dincer wrote:debug creates a new scope.Hi, what do you think should have been in lieu of runtime error? ...Related: there is a version statement, resembling `{$ifdef}` in Pascal or `#ifdef` in C, but arguably cleaner. Consider this: ``` struct Ana { char a; version (v1) {Kedi k;} // assertions complated union { char b; char p; } union Kedi { char cat; char edi; } } ``` Then compile with `dmd -version v3` or the like. Note that the `{}` for compile-time features (such as `version`, `debug` or `static if`) don't introduce a new scope. Ivan Kazmenko.
Aug 15 2022
On Tuesday, 16 August 2022 at 06:16:23 UTC, bauss wrote:On Monday, 15 August 2022 at 16:34:29 UTC, Ivan Kazmenko wrote:Hmm, on the contrary, this works for me (dmd 2.0.100): ``` debug {int i;} else {long i;} pragma (msg, typeof (i)); void main () {i = 2;} ``` Ivan Kazmenko.Note that the `{}` for compile-time features (such as `version`, `debug` or `static if`) don't introduce a new scope. Ivan Kazmenko.debug creates a new scope.
Aug 16 2022
On Tuesday, 16 August 2022 at 06:16:23 UTC, bauss wrote:debug creates a new scope.debug and version work exactly the same way. there's no new scope.
Aug 16 2022