String interpolation

2020-05-21 Thread Patrick Schluter via Digitalmars-d-learn
https://forum.dlang.org/post/prlulfqvxrgrdzxot...@forum.dlang.org On Tuesday, 10 November 2015 at 11:22:56 UTC, wobbles wrote: int a = 1; int b = 4; writefln("The number %s is less than %s", a, b); writeln("The number ",a, " is less than ",b);

String interpolation

2015-11-10 Thread tired_eyes via Digitalmars-d-learn
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("little", "whi

String interpolation

2016-01-06 Thread Guillaume Piolat via Digitalmars-d-learn
Is there a fancy way to have some kind of string interpolation in D?

Re: String interpolation

2020-05-20 Thread mw via Digitalmars-d-learn
does not match template declaration interp(X) i.d(11): Error: template instance interp!"The number #{a} is less than #{b}" does not match template declaration interp(X) I'm wondering if this code has once worked? and seems dpaste.dzfl.pl no longer there. Can we do string interpol

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-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-interpolat

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:/

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 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 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 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 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 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:/

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

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

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

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 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 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 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 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 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

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

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#s

Want to try out string interpolation in D?

2023-10-20 Thread Imperatorn via Digitalmars-d-learn
stallation folder Example: ``` copy generated\windows\release\64\dmd.exe C:\d\dmd2\windows\bin64 ``` Copy druntime/src/core/interpolation.d to your corresponding druntime folder + import Example: ``` copy druntime/src/core/interpolation.d C:\d\dmd2\src\druntime\import\core\ ``` Now

Re: Want to try out string interpolation in D?

2023-10-20 Thread Imperatorn via Digitalmars-d-learn
On Friday, 20 October 2023 at 16:41:40 UTC, Imperatorn wrote: Here's a script to get you started ```bash git clone https://github.com/adamdruppe/dmd.git cd dmd git checkout interp rdmd compiler/src/build.d ``` [...] We just need support for it in the tools, then D will be a Dream come true

Re: Want to try out string interpolation in D?

2023-10-22 Thread Imperatorn via Digitalmars-d-learn
On Friday, 20 October 2023 at 16:41:40 UTC, Imperatorn wrote: Here's a script to get you started Same instructions for DIP1027: ``` git clone https://github.com/WalterBright/dmd.git cd dmd git checkout dip1027 rdmd compiler/src/build.d ``` Then same instructions as above but without the need

Re: Want to try out string interpolation in D?

2023-10-23 Thread matheus via Digitalmars-d-learn
On Friday, 20 October 2023 at 16:41:40 UTC, Imperatorn wrote: Here's a script to get you started ... Now try string interpolation: ```d import std.stdio; void main() { string name = "Johan"; int age = 37; int iq = 8001; int coffees = 1000;

Re: Want to try out string interpolation in D?

2023-10-23 Thread Imperatorn via Digitalmars-d-learn
On Monday, 23 October 2023 at 11:12:20 UTC, matheus wrote: On Friday, 20 October 2023 at 16:41:40 UTC, Imperatorn wrote: Here's a script to get you started ... Now try string interpolation: ```d import std.stdio; void main() { string name = "Johan"; int age =

Re: Want to try out string interpolation in D?

2023-10-27 Thread Imperatorn via Digitalmars-d-learn
On Monday, 23 October 2023 at 11:43:33 UTC, Imperatorn wrote: On Monday, 23 October 2023 at 11:12:20 UTC, matheus wrote: On Friday, 20 October 2023 at 16:41:40 UTC, Imperatorn wrote: [...] First of all thanks for writing this. Well this seems pretty nice... What DIP number is this? - I'd li