Re: Special Code String for mixins

2018-03-14 Thread Sebastiaan Koppe via Digitalmars-d
On Wednesday, 14 March 2018 at 15:50:13 UTC, Jonathan Marler wrote: I've got a PR for dmd (https://github.com/dlang/dmd/pull/7988) that implements "interpolated strings" which makes generating code with strings MUCH nicer, i.e. Really nice. :thumbs-up:

Re: Special Code String for mixins

2018-03-14 Thread Stefan Koch via Digitalmars-d
On Wednesday, 14 March 2018 at 15:50:13 UTC, Jonathan Marler wrote: On Wednesday, 15 March 2017 at 13:50:28 UTC, Inquie wrote: [...] I've got a PR for dmd (https://github.com/dlang/dmd/pull/7988) that implements "interpolated strings" which makes generating code with strings MUCH nicer, i.e.

Re: Special Code String for mixins

2018-03-14 Thread Jonathan Marler via Digitalmars-d
On Wednesday, 15 March 2017 at 13:50:28 UTC, Inquie wrote: I hate building code strings for string mixins as it's very ugly and seems like a complete hack. How bout, instead, we have a special code string similar to a multiline string that allows us to represent valid D code. The compiler can

Re: Special Code String for mixins

2018-03-14 Thread Robert M. Münch via Digitalmars-d
On 2017-03-15 13:50:28 +, Inquie said: I hate building code strings for string mixins as it's very ugly and seems like a complete hack. ... Even a bit old, I would like to pick-up this topic, as I totally agree with the statement. Thinking this a bit further, it would be very nice to h

Re: Special Code String for mixins

2017-03-15 Thread Nick Sabalausky (Abscissa) via Digitalmars-d
On 03/15/2017 11:50 AM, Stefan Koch wrote: Wish I could get rid of the need for "mixin(...)" in interp though. But you can. in interp you can evoke the function you generate however for that you need to pass s to it. Thus reinventing writef and defeating the whole point of interpolated stri

Re: Special Code String for mixins

2017-03-15 Thread H. S. Teoh via Digitalmars-d
On Wed, Mar 15, 2017 at 01:50:28PM +, Inquie via Digitalmars-d wrote: > I hate building code strings for string mixins as it's very ugly and seems > like a complete hack. > > How bout, instead, we have a special code string similar to a multiline > string that allows us to represent valid D co

Re: Special Code String for mixins

2017-03-15 Thread Stefan Koch via Digitalmars-d
On Wednesday, 15 March 2017 at 15:39:38 UTC, Nick Sabalausky (Abscissa) wrote: On 03/15/2017 09:50 AM, Inquie wrote: e.g., string s = "smile"; enum code1 = @# void happyCode = "Makes me @@s@@"; #@ enum code2 = code1 ~ @# int ImThisHappy = @@s.length@@; #@ mixin(code); import scriptlike; /

Re: Special Code String for mixins

2017-03-15 Thread Nick Sabalausky (Abscissa) via Digitalmars-d
On 03/15/2017 09:50 AM, Inquie wrote: e.g., string s = "smile"; enum code1 = @# void happyCode = "Makes me @@s@@"; #@ enum code2 = code1 ~ @# int ImThisHappy = @@s.length@@; #@ mixin(code); import scriptlike; // https://github.com/Abscissa/scriptlike string s = "smile"; // http://semitwi

Re: Special Code String for mixins

2017-03-15 Thread Inquie via Digitalmars-d
On Wednesday, 15 March 2017 at 14:12:57 UTC, Adam D. Ruppe wrote: On Wednesday, 15 March 2017 at 13:50:28 UTC, Inquie wrote: I hate building code strings for string mixins as it's very ugly and seems like a complete hack. Me too, that's why I avoid doing it. Check out my tips of the week here

Re: Special Code String for mixins

2017-03-15 Thread Shachar Shemesh via Digitalmars-d
On 15/03/17 15:50, Inquie wrote: I hate building code strings for string mixins as it's very ugly and seems like a complete hack. What I usually do is use the q{} format. Vim does syntax highlighting on it: string code = q{ immutable int a = %s; }.format(something); ... mixin(

Re: Special Code String for mixins

2017-03-15 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 15 March 2017 at 13:50:28 UTC, Inquie wrote: I hate building code strings for string mixins as it's very ugly and seems like a complete hack. Me too, that's why I avoid doing it. Check out my tips of the week here: http://arsdnet.net/this-week-in-d/sep-20.html and here: http://a

Re: Special Code String for mixins

2017-03-15 Thread Inquie via Digitalmars-d
On Wednesday, 15 March 2017 at 13:50:28 UTC, Inquie wrote: I hate building code strings for string mixins as it's very ugly and seems like a complete hack. How bout, instead, we have a special code string similar to a multiline string that allows us to represent valid D code. The compiler can

Special Code String for mixins

2017-03-15 Thread Inquie via Digitalmars-d
I hate building code strings for string mixins as it's very ugly and seems like a complete hack. How bout, instead, we have a special code string similar to a multiline string that allows us to represent valid D code. The compiler can then verify the string after compilation to make sure it i