Re: String interpolation

2020-05-21 Thread mw via Digitalmars-d-learn
On Thursday, 21 May 2020 at 06:57:28 UTC, mw wrote: On Thursday, 21 May 2020 at 01:13:27 UTC, Paul Backus wrote: On Wednesday, 20 May 2020 at 23:41:15 UTC, mw wrote: Can we do string interpolation in D now? There's an implementation in the dub package "scriptlike": https://code.dlang.org/pac

Re: String interpolation

2020-05-21 Thread ZK via Digitalmars-d-learn
On Thursday, 21 May 2020 at 17:17:49 UTC, Adam D. Ruppe wrote: On Thursday, 21 May 2020 at 17:10:31 UTC, mw wrote: BTW, is the .idup must be there? It is discussed more in the github document but basically the proposed built-in syntax returns a generic builder thing which can make more than

Re: String interpolation

2020-05-21 Thread ZK via Digitalmars-d-learn
On Thursday, 21 May 2020 at 18:12:01 UTC, ZK wrote: I love the extensibility of this, but perhaps there should be something like `ii"foo".idup` that's syntactic sugar for `i"foo".idup`. New users might get confused by the need for appending idup, and then they'll think about how other language

Re: String interpolation

2020-05-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 May 2020 at 17:10:31 UTC, mw wrote: BTW, is the .idup must be there? It is discussed more in the github document but basically the proposed built-in syntax returns a generic builder thing which can make more than just strings. The idup specifically asks it to make a copy into

Re: String interpolation

2020-05-21 Thread mw via Digitalmars-d-learn
On Thursday, 21 May 2020 at 12:53:50 UTC, Adam D. Ruppe wrote: On Thursday, 21 May 2020 at 06:57:28 UTC, mw wrote: i.e how to write this 's'? gimme a like on the proposal to add to the language! https://github.com/dlang/DIPs/pull/186 If accepted, that would let you write i"stuff here".idup

Re: String interpolation

2020-05-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 May 2020 at 06:57:28 UTC, mw wrote: i.e how to write this 's'? gimme a like on the proposal to add to the language! https://github.com/dlang/DIPs/pull/186 If accepted, that would let you write i"stuff here".idup to get an interpolated string.

Re: String interpolation

2020-05-21 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 21 May 2020 at 06:57:28 UTC, mw wrote: On Thursday, 21 May 2020 at 01:13:27 UTC, Paul Backus wrote: On Wednesday, 20 May 2020 at 23:41:15 UTC, mw wrote: Can we do string interpolation in D now? There's an implementation in the dub package "scriptlike": https://code.dlang.org/pac

Re: String interpolation

2020-05-21 Thread mw via Digitalmars-d-learn
On Thursday, 21 May 2020 at 01:13:27 UTC, Paul Backus wrote: On Wednesday, 20 May 2020 at 23:41:15 UTC, mw wrote: Can we do string interpolation in D now? There's an implementation in the dub package "scriptlike": https://code.dlang.org/packages/scriptlike#string-interpolation Thank you! ve

Re: String interpolation

2020-05-20 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 23:41:15 UTC, mw wrote: Can we do string interpolation in D now? There's an implementation in the dub package "scriptlike": https://code.dlang.org/packages/scriptlike#string-interpolation

Re: String interpolation

2020-05-20 Thread mw via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 13:36:44 UTC, Andrea Fontana wrote: On Tuesday, 10 November 2015 at 12:40:07 UTC, Márcio Martins wrote: writeln(interp!"The number #{a} is less than #{b}"); Quite pleasant syntax this way :) Not sure if it's feasible to do this on the language side. Yes. Here a

Re: String interpolation

2016-01-06 Thread Meta via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 23:30:22 UTC, Guillaume Piolat wrote: Is there a fancy way to have some kind of string interpolation in D? This is probably the best you're going to be able to do in D in regards to string interpolation. https://github.com/Abscissa/scriptlike#string-interpolat

Re: String interpolation

2016-01-06 Thread cym13 via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 23:30:22 UTC, Guillaume Piolat wrote: Is there a fancy way to have some kind of string interpolation in D? Other than std.format.format that is?

Re: String interpolation

2015-11-10 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 12:40:07 UTC, Márcio Martins wrote: writeln(interp!"The number #{a} is less than #{b}"); Quite pleasant syntax this way :) Not sure if it's feasible to do this on the language side. Yes. Here a (stupid!) proof of concept: http://dpaste.dzfl.pl/74b1a4e3c8c6

Re: String interpolation

2015-11-10 Thread Márcio Martins via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 11:29:32 UTC, TheFlyingFiddle wrote: On Tuesday, 10 November 2015 at 10:41:52 UTC, tired_eyes wrote: On Tuesday, 10 November 2015 at 10:33:30 UTC, Tobias Pankrath wrote: Ruby: a = 1 b = 4 puts "The number #{a} is less than #{b}" PHP: $a = 1; $b = 4; echo "The nu

Re: String interpolation

2015-11-10 Thread tired_eyes via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 11:29:32 UTC, TheFlyingFiddle wrote: On Tuesday, 10 November 2015 at 10:41:52 UTC, tired_eyes wrote: On Tuesday, 10 November 2015 at 10:33:30 UTC, Tobias Pankrath wrote: Ruby: a = 1 b = 4 puts "The number #{a} is less than #{b}" PHP: $a = 1; $b = 4; echo "The nu

Re: String interpolation

2015-11-10 Thread tcak via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 11:22:56 UTC, wobbles wrote: On Tuesday, 10 November 2015 at 10:41:52 UTC, tired_eyes wrote: On Tuesday, 10 November 2015 at 10:33:30 UTC, Tobias Pankrath wrote: On Tuesday, 10 November 2015 at 10:21:32 UTC, tired_eyes wrote: [...] std.string.format and std.fo

Re: String interpolation

2015-11-10 Thread TheFlyingFiddle via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 10:41:52 UTC, tired_eyes wrote: On Tuesday, 10 November 2015 at 10:33:30 UTC, Tobias Pankrath wrote: Ruby: a = 1 b = 4 puts "The number #{a} is less than #{b}" PHP: $a = 1; $b = 4; echo "The number $a is less than $b"; D: ??? int a = 1, b = 4; writefln("The nu

Re: String interpolation

2015-11-10 Thread wobbles via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 10:41:52 UTC, tired_eyes wrote: On Tuesday, 10 November 2015 at 10:33:30 UTC, Tobias Pankrath wrote: On Tuesday, 10 November 2015 at 10:21:32 UTC, tired_eyes wrote: [...] std.string.format and std.format are the standard options. What are you missing? Ruby:

Re: String interpolation

2015-11-10 Thread tired_eyes via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 10:33:30 UTC, Tobias Pankrath wrote: On Tuesday, 10 November 2015 at 10:21:32 UTC, tired_eyes wrote: Hi, The only example of string interpolation I've found so far is on Rosetta Code: void main() { import std.stdio, std.string; "Mary had a %s lamb.".fo

Re: String interpolation

2015-11-10 Thread Tobias Pankrath via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 10:21:32 UTC, tired_eyes wrote: Hi, The only example of string interpolation I've found so far is on Rosetta Code: void main() { import std.stdio, std.string; "Mary had a %s lamb.".format("little").writeln; "Mary had a %2$s %1$s lamb.".format("littl

Re: String interpolation

2015-11-10 Thread wobbles via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 10:21:32 UTC, tired_eyes wrote: Hi, The only example of string interpolation I've found so far is on Rosetta Code: void main() { import std.stdio, std.string; "Mary had a %s lamb.".format("little").writeln; "Mary had a %2$s %1$s lamb.".format("littl