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

2018-01-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 26, 2018 14:23:20 Oleksii Skidan via Digitalmars-d-learn wrote: > 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 > >

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

2018-01-26 Thread timotheecour via Digitalmars-d-learn
On Friday, 26 January 2018 at 11:18:21 UTC, Oleksii Skidan wrote: 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

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

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 > > wrote: >> [...]

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

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

2018-01-26 Thread Seb via Digitalmars-d-learn
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 also https://code.dlang.org/packages/fluent-asserts which

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

2018-01-26 Thread Jonathan M Davis via Digitalmars-d-learn
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 > > > > wrote: > >> I could imagine a mixin-based solution in D: > >> ```d > >> //

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

2018-01-26 Thread Basile B. 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.

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.

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

2018-01-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 26, 2018 11:32:42 Mike Parker via Digitalmars-d-learn 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

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

2018-01-26 Thread Mike Parker via Digitalmars-d-learn
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. Secondly, neither IDEs nor advanced text editors are able to figure

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

2018-01-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 26, 2018 11:18:21 Oleksii Skidan via Digitalmars-d-learn wrote: > 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

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