Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 04, 2020 D string interpolation | ||||
---|---|---|---|---|
| ||||
Are there any easy ways to achieve string interpolation in D a la $"Hello {adjective} world"? Thanks |
October 04, 2020 Re: D string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Imperatorn | On Sunday, 4 October 2020 at 13:16:53 UTC, Imperatorn wrote: > Are there any easy ways to achieve string interpolation in D a la $"Hello {adjective} world"? > > Thanks Currently, no. There's a DIP from Adam and Steve currently going through the review process. It recently completed the first round of community review. They intend to make significant revisions, so it will require at least one more round of community review before moving forward. DIP 1036: https://github.com/dlang/DIPs/blob/master/DIPs/DIP1036.md The review summary and links to the discussion & feedback threads: https://github.com/dlang/DIPs/blob/master/DIPs/DIP1036.md#reviews DIP 1036 was an iteration on an earlier DIP by Walter that he and Atila ultimately rejected: https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1027.md |
October 04, 2020 Re: D string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Imperatorn | On Sunday, 4 October 2020 at 13:16:53 UTC, Imperatorn wrote: > Are there any easy ways to achieve string interpolation in D a la $"Hello {adjective} world"? > > Thanks https://code.dlang.org/packages/scriptlike#string-interpolation |
October 04, 2020 Re: D string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Sunday, 4 October 2020 at 14:04:04 UTC, Mike Parker wrote:
> On Sunday, 4 October 2020 at 13:16:53 UTC, Imperatorn wrote:
>> [...]
>
> Currently, no. There's a DIP from Adam and Steve currently going through the review process. It recently completed the first round of community review. They intend to make significant revisions, so it will require at least one more round of community review before moving forward.
>
> DIP 1036:
> https://github.com/dlang/DIPs/blob/master/DIPs/DIP1036.md
>
> The review summary and links to the discussion & feedback threads:
> https://github.com/dlang/DIPs/blob/master/DIPs/DIP1036.md#reviews
>
> DIP 1036 was an iteration on an earlier DIP by Walter that he and Atila ultimately rejected:
> https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1027.md
Splendid!
|
October 04, 2020 Re: D string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Sunday, 4 October 2020 at 14:19:17 UTC, Paul Backus wrote:
> On Sunday, 4 October 2020 at 13:16:53 UTC, Imperatorn wrote:
>> Are there any easy ways to achieve string interpolation in D a la $"Hello {adjective} world"?
>>
>> Thanks
>
> https://code.dlang.org/packages/scriptlike#string-interpolation
Looks like an acceptable workaround for now. Thanks!
|
October 04, 2020 Re: D string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Imperatorn | On Sunday, 4 October 2020 at 13:16:53 UTC, Imperatorn wrote: > Are there any easy ways to achieve string interpolation in D a la $"Hello {adjective} world"? I also have one: https://code.dlang.org/packages/jdiutil ``` // multiple vars separated by ';' // _S with var name; _s without var name writeln(mixin(_S!"with var name: {i; d; thePoint}")); writeln(mixin(_s!"without var name: {i; d; thePoint}")); ``` |
October 04, 2020 Re: D string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to mw | On Sunday, 4 October 2020 at 16:27:59 UTC, mw wrote:
> On Sunday, 4 October 2020 at 13:16:53 UTC, Imperatorn wrote:
>> Are there any easy ways to achieve string interpolation in D a la $"Hello {adjective} world"?
>
> I also have one:
>
> https://code.dlang.org/packages/jdiutil
>
> ```
> // multiple vars separated by ';'
> // _S with var name; _s without var name
> writeln(mixin(_S!"with var name: {i; d; thePoint}"));
> writeln(mixin(_s!"without var name: {i; d; thePoint}"));
> ```
Cool
|
October 04, 2020 Re: D string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Imperatorn | On Sunday, 4 October 2020 at 16:31:50 UTC, Imperatorn wrote:
> On Sunday, 4 October 2020 at 16:27:59 UTC, mw wrote:
>> On Sunday, 4 October 2020 at 13:16:53 UTC, Imperatorn wrote:
>>> Are there any easy ways to achieve string interpolation in D a la $"Hello {adjective} world"?
>>
>> I also have one:
>>
>> https://code.dlang.org/packages/jdiutil
>>
>> ```
>> // multiple vars separated by ';'
>> // _S with var name; _s without var name
>> writeln(mixin(_S!"with var name: {i; d; thePoint}"));
>> writeln(mixin(_s!"without var name: {i; d; thePoint}"));
>> ```
multiple vars separated by ';'
because, you can also pass in `funcCAll(arg, arg2)`
|
October 04, 2020 Re: D string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Sunday, 4 October 2020 at 14:04:04 UTC, Mike Parker wrote: > On Sunday, 4 October 2020 at 13:16:53 UTC, Imperatorn wrote: >> [...] > > [...] so it will require at least one more round of community review before moving forward. > > DIP 1036: > https://github.com/dlang/DIPs/blob/master/DIPs/DIP1036.md I hope they change the syntax to favor readers of code, not writers. As with D's templates, reading code is made more difficult by needlessly adding syntactical variations for language features. Example: writefln(i"I ate $apples and ${%d}bananas totaling $(apples + bananas) fruit."); > $apples > $(apples + bananas) If I was trying to quickly scan code to pick out variables, there's two different things I would have to look for. Example: > Foo!int > Foo!(bool, int) Same problem. > Foo; > Foo(); Same problem. I'm not sure if the reasoning is to try and reduce noise in the "common" case, or to appease people that think not having to type () will actually help them get things done faster, but neither reason seems valid to me. Also, why would the less significant part of the construct be in the curly braces? > ${%d}bananas Why not like this? > i"{apples} bar" > i"{apples + bananas} bar" > i"{bananas:%d} bar" > Bar!(int) > Bar!(bool, int) > Bar(); > Bar(); In all honesty, part of the reason I lost interest in D is because of the type of quirks listed above. I don't believe the intended benefit, whatever it may be, is worth the sacrifice of consistency. |
October 04, 2020 Re: D string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to bitwise | On Sunday, 4 October 2020 at 17:53:55 UTC, bitwise wrote:
> I hope they change the syntax
The new draft ditches most the old syntax.
Not much point talking about it until it is released though, but you'll probably like the new draft a lot more.
|
Copyright © 1999-2021 by the D Language Foundation