Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support string interpolation #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

FeepingCreature
Copy link
Collaborator

Support string interpolation added in DMD 2.108, ie. log.info(i"The answer is $(42)");.

Older compilers remain supported.

@FeepingCreature FeepingCreature force-pushed the fix/support-string-interpolation branch from 6c4995a to 6f098b2 Compare May 15, 2024 08:26
example.d Show resolved Hide resolved
src/util/log.d Outdated Show resolved Hide resolved
@@ -185,11 +212,11 @@ struct Log

// Helper to allow using named references in format strings, ie. treat %{name} equivalent to %s.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's intended for this idea in the future? Will it be deprecated?
Or does it have to be extended like $foo(42)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was intending for it to correspond to named arguments eventually; I think that's still useful. I'd leave it for now. We need more experience with how interpolated strings and named args look in practice.

src/util/log.d Outdated Show resolved Hide resolved
Copy link
Member

@linkrope linkrope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to continue with "%{name}"?

@FeepingCreature FeepingCreature force-pushed the fix/support-string-interpolation branch from 6f098b2 to d38ab58 Compare June 13, 2024 09:46
@FeepingCreature FeepingCreature force-pushed the fix/support-string-interpolation branch from d38ab58 to 86326d8 Compare June 13, 2024 09:49
static if (supportsStringInterpolation)
{
// Placeholder pending https://issues.dlang.org/show_bug.cgi?id=24550
private void formattedWrite(Sink, Args...)(ref Sink sink, InterpolationHeader _header, Args args,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicer line break?

private void formattedWrite(Sink, Args...)(ref Sink sink,
    InterpolationHeader _header, Args args, InterpolationFooter _footer)

Copy link
Member

@linkrope linkrope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just make the line break prettier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants