Re: ImportC: Should this compile?

2021-12-19 Thread bachmeier via Digitalmars-d-learn
to fix it while keeping the same behavior and performance? Unless C11 has changed the rules about nested initializers, that should compile. You might try explicit nesting: ```d stb_easy_font_color c = { {255,255,255,255} }; ``` And please file an issue if there isn't one already. (I don't

Re: ImportC: Should this compile?

2021-12-18 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 19 December 2021 at 03:27:50 UTC, Tejas wrote: Oh wow, the executable gets named `stuff` if that's the first file passed... always thought it would name it the same name as that file which contained `main` If the name of the file with `main` were used, you'd have to have a

Re: ImportC: Should this compile?

2021-12-18 Thread Tejas via Digitalmars-d-learn
to fix it while keeping the same behavior and performance? Unless C11 has changed the rules about nested initializers, that should compile. You might try explicit nesting: ```d stb_easy_font_color c = { {255,255,255,255} }; ``` And please file an issue if there isn't one already. (I don't

Re: ImportC: Should this compile?

2021-12-18 Thread Mike Parker via Digitalmars-d-learn
? Unless C11 has changed the rules about nested initializers, that should compile. You might try explicit nesting: ```d stb_easy_font_color c = { {255,255,255,255} }; ``` And please file an issue if there isn't one already. (I don't know what struct __tag21 is. It's not anywhere in the source

ImportC: Should this compile?

2021-12-18 Thread bachmeier via Digitalmars-d-learn
I've been trying to get the stb header library to compile. There's a single remaining failure: ``` typedef struct { unsigned char c[4]; } stb_easy_font_color; stb_easy_font_color c = { 255,255,255,255 }; // use structure copying to avoid needing depending on memcpy() ``` LDC returns ```

Re: Struct initialization extra comma - should it compile

2021-04-25 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 25 April 2021 at 13:39:54 UTC, JN wrote: struct Foo { int x, y, z; } void main() { Foo bar = Foo(1,); } This compiles without syntax errors, is this expected? Yes, the

Re: Struct initialization extra comma - should it compile

2021-04-25 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 25 April 2021 at 13:39:54 UTC, JN wrote: struct Foo { int x, y, z; } void main() { Foo bar = Foo(1,); } This compiles without syntax errors, is this expected? Yes, D allows trailing commas in argument lists.

Struct initialization extra comma - should it compile

2021-04-25 Thread JN via Digitalmars-d-learn
struct Foo { int x, y, z; } void main() { Foo bar = Foo(1,); } This compiles without syntax errors, is this expected?

Re: Should it compile?

2020-06-07 Thread Stanislav Blinov via Digitalmars-d-learn
On Sunday, 7 June 2020 at 23:09:41 UTC, Jack Applegame wrote: auto const_ua = Unique!(const NonCopyable)(move(ca)); // error, why??? } ``` Moving *from* a const would violate const. At least, until such time that the compiler is finally taught about move() (hopefully, sometime this

Re: Should it compile?

2020-06-07 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 7 June 2020 at 23:09:41 UTC, Jack Applegame wrote: const NonCopyable const_a; auto const_ua = Unique!(const NonCopyable)(move(ca)); // error, why??? You can't move from a const variable.

Re: Should it compile?

2020-06-07 Thread Jack Applegame via Digitalmars-d-learn
On Saturday, 6 June 2020 at 11:58:06 UTC, Basile B. wrote: maybe it shouldn't but then with another message, for example Error, cannot `void` initialize a `const` declaration. since that makes very little sense, at least as a local variable. (as a member, this can be initialized in a

Re: Should it compile?

2020-06-07 Thread Jack Applegame via Digitalmars-d-learn
On Saturday, 6 June 2020 at 12:02:03 UTC, MoonlightSentinel wrote: On Saturday, 6 June 2020 at 08:55:20 UTC, Jack Applegame wrote: Should it compile? No, moveEmplace just sees a const reference and doesn't know that a is void-initialized. Actually, it knows. Because moveEmplace assumes

Re: Should it compile?

2020-06-06 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 6 June 2020 at 12:54:38 UTC, Stanislav Blinov wrote: The moveEmpalce should compile... But not when the *first* argument is const though, like in the example. For *that*, one would have to insert an additional cast.

Re: Should it compile?

2020-06-06 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 6 June 2020 at 11:58:06 UTC, Basile B. wrote: On Saturday, 6 June 2020 at 08:55:20 UTC, Jack Applegame wrote: Should it compile? I think, it should. maybe it shouldn't but then with another message, for example Error, cannot `void` initialize a `const` declaration. since

Re: Should it compile?

2020-06-06 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 6 June 2020 at 08:55:20 UTC, Jack Applegame wrote: Should it compile? No, moveEmplace just sees a const reference and doesn't know that a is void-initialized.

Re: Should it compile?

2020-06-06 Thread Basile B. via Digitalmars-d-learn
On Saturday, 6 June 2020 at 08:55:20 UTC, Jack Applegame wrote: Should it compile? ```d import std.algorithm.mutation; void main() { const char a = void; const char b ='b'; moveEmplace(b, a); // mutation.d: Error: cannot modify const expression target assert(a == 'b

Should it compile?

2020-06-06 Thread Jack Applegame via Digitalmars-d-learn
Should it compile? ```d import std.algorithm.mutation; void main() { const char a = void; const char b ='b'; moveEmplace(b, a); // mutation.d: Error: cannot modify const expression target assert(a == 'b'); } ``` I think, it should.

Re: DIP1000: Should this compile

2019-05-16 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 16 May 2019 at 21:56:52 UTC, Steven Schveighoffer wrote: On 5/16/19 10:21 PM, Max Haughton wrote: https://run.dlang.io/is/cKFsXh Should this compile, or is return scope T* down to the user to not escape (Returning directly does not compile) Answer to subject

Re: DIP1000: Should this compile

2019-05-16 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 16 May 2019 at 21:21:51 UTC, Max Haughton wrote: https://run.dlang.io/is/cKFsXh Should this compile, or is return scope T* down to the user to not escape (Returning directly does not compile) This is a bug, as can be showed by repeating the call to (*boi).writeln - suddenly

Re: DIP1000: Should this compile

2019-05-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/16/19 10:21 PM, Max Haughton wrote: https://run.dlang.io/is/cKFsXh Should this compile, or is return scope T* down to the user to not escape (Returning directly does not compile) Answer to subject: no. This is a bug. Please file. Not sure what the solution is, because dip1000 makes

DIP1000: Should this compile

2019-05-16 Thread Max Haughton via Digitalmars-d-learn
https://run.dlang.io/is/cKFsXh Should this compile, or is return scope T* down to the user to not escape (Returning directly does not compile)

Re: Should this Compile?

2017-10-03 Thread SamwiseFilmore via Digitalmars-d-learn
On Tuesday, 3 October 2017 at 23:13:00 UTC, Jonathan M Davis wrote: On Tuesday, October 03, 2017 22:42:35 SamwiseFilmore via Digitalmars-d-learn wrote: On Tuesday, 3 October 2017 at 22:37:17 UTC, SamwiseFilmore wrote: > Am I using the ternary operator correctly here, or is this > an issue with

Re: Should this Compile?

2017-10-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 03, 2017 22:42:35 SamwiseFilmore via Digitalmars-d-learn wrote: > On Tuesday, 3 October 2017 at 22:37:17 UTC, SamwiseFilmore wrote: > > Am I using the ternary operator correctly here, or is this an > > issue with dmd? I'm using dmd v2.076.0. > > I wrapped the ternary in

Re: Should this Compile?

2017-10-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 03, 2017 at 10:37:17PM +, SamwiseFilmore via Digitalmars-d-learn wrote: [...] > string toString() { > return > this.value.toString() ~ > " of " ~ > this.suit.toString() ~ > this.suit == CardSuit.diamonds ? "" : "\t" ~ >

Re: Should this Compile?

2017-10-03 Thread SamwiseFilmore via Digitalmars-d-learn
On Tuesday, 3 October 2017 at 22:37:17 UTC, SamwiseFilmore wrote: Am I using the ternary operator correctly here, or is this an issue with dmd? I'm using dmd v2.076.0. I wrapped the ternary in parentheses, and it compiled. Still, I'm wondering about this behavior.

Should this Compile?

2017-10-03 Thread SamwiseFilmore via Digitalmars-d-learn
I've created toString() for a struct (which is a lot more complicated than what I've provided here) that returns a large number of concatenated strings. Here is the example: struct Card { // Flesh out these enums appropriately CardSuit suit; CardValue value; Facing facing;

Re: Should this compile?

2015-08-26 Thread tchaloupka via Digitalmars-d-learn
On Tuesday, 25 August 2015 at 18:29:08 UTC, Vladimir Panteleev wrote: I think this is a bug, but is easily worked around with: auto test(string a) { return .test(a, b); } Thanks, this worked. Filled it: https://issues.dlang.org/show_bug.cgi?id=14965

Re: Should this compile?

2015-08-26 Thread Timon Gehr via Digitalmars-d-learn
On 08/25/2015 08:29 PM, Vladimir Panteleev wrote: I think this is a bug, but is easily worked around with: auto test(string a) { return .test(a, b); } I suspect that the reason the error occurs, is that the auto return type automatically rewrites the function declaration into an

Re: Should this compile?

2015-08-26 Thread Timon Gehr via Digitalmars-d-learn
On 08/26/2015 09:55 PM, Timon Gehr wrote: On 08/25/2015 08:29 PM, Vladimir Panteleev wrote: I think this is a bug, but is easily worked around with: auto test(string a) { return .test(a, b); } I suspect that the reason the error occurs, is that the auto return type automatically

Re: Should this compile?

2015-08-26 Thread Meta via Digitalmars-d-learn
On Wednesday, 26 August 2015 at 20:02:35 UTC, Timon Gehr wrote: Another workaround is to order the declarations in the opposite way: import std.stdio; import std.range : chain; auto test(string a,string b) { return chain(a,b); } auto test(string a) { return test(a,b); } void main() {

Should this compile?

2015-08-25 Thread tchaloupka via Digitalmars-d-learn
import std.stdio; import std.range : chain; auto test(string a) { return test(a, b); } auto test(string a, string b) { return chain(a, b); } void main() { writeln(test(a)); } Ends with: Error: forward reference to inferred return type of function call 'test' I know this exact

Re: Should this compile?

2015-08-25 Thread Vladimir Panteleev via Digitalmars-d-learn
On Tuesday, 25 August 2015 at 18:19:40 UTC, tchaloupka wrote: import std.stdio; import std.range : chain; auto test(string a) { return test(a, b); } auto test(string a, string b) { return chain(a, b); } void main() { writeln(test(a)); } Ends with: Error: forward reference to