Re: Strange compiler error. Whose bug is that?

2018-01-27 Thread Oleksii Skidan via Digitalmars-d-learn
On Saturday, 27 January 2018 at 08:18:07 UTC, thedeemon wrote: On Friday, 26 January 2018 at 21:17:14 UTC, Oleksii Skidan wrote: struct Game { Triangle player = new Triangle; When you initialize a struct member like this, compiler tries to calculate the initial value and remember it as

Re: Is it possible to obtain textual representation of an arbitary code?

2018-01-26 Thread Oleksii Skidan via Digitalmars-d-learn
On Friday, 26 January 2018 at 13:25:12 UTC, Seb wrote: On Friday, 26 January 2018 at 13:05:26 UTC, Jonathan M Davis wrote: If you don't think that simply using assertions for unit tests is good enough, then I'd suggest that you look at https://code.dlang.org/packages/unit-threaded There's als

Strange compiler error. Whose bug is that?

2018-01-26 Thread Oleksii Skidan via Digitalmars-d-learn
Hi, I get a strange error: ``` λ dub build Performing "debug" build using D:\d\dmd2\windows\bin\dmd.exe for x86. strange ~master: building configuration "application"... source\app.d(24,18): Error: non-constant expression &[Particle(1.0F, 1.0F, 1.0F), Particle(2.0F, 2.0F,

Re: Is it possible to obtain textual representation of an arbitary code?

2018-01-26 Thread Oleksii Skidan via Digitalmars-d-learn
On Friday, 26 January 2018 at 13:05:26 UTC, Jonathan M Davis wrote: On Friday, January 26, 2018 12:30:03 Oleksii Skidan via Digitalmars-d-learn wrote: On Friday, 26 January 2018 at 11:32:42 UTC, Mike Parker wrote: > On Friday, 26 January 2018 at 11:18:21 UTC, Oleksii Skidan > &

Re: Is it possible to obtain textual representation of an arbitary code?

2018-01-26 Thread Oleksii Skidan via Digitalmars-d-learn
On Friday, 26 January 2018 at 13:05:26 UTC, Jonathan M Davis wrote: Why are you using strings for any of this? Printing out the expression is kind of pointless. If you have the file and line number (which an AssertError will give you), then you know where the failure is, and you can see the exp

Re: Is it possible to obtain textual representation of an arbitary code?

2018-01-26 Thread Oleksii Skidan via Digitalmars-d-learn
On Friday, 26 January 2018 at 11:32:42 UTC, Mike Parker wrote: On Friday, 26 January 2018 at 11:18:21 UTC, Oleksii Skidan wrote: I could imagine a mixin-based solution in D: ```d // Usage: ASSERT!"a == b"; ``` But it seems a bit alien to me. First of all, it kind of stringly-typed one. Secon

Is it possible to obtain textual representation of an arbitary code?

2018-01-26 Thread Oleksii Skidan via Digitalmars-d-learn
Hi, I wonder if it's possible to convert D language code into a string at compile time? C/C++ preprocessor has this feature built-in: `#` preprocessing operator allows converting a macro argument into a string constant. See the following code snippet for example: ```cplusplus #define ASSERT