-
-
Notifications
You must be signed in to change notification settings - Fork 379
Add Interpolation Expression Sequences to the spec #3768
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
Conversation
Thanks for your pull request, @schveiguy! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
b3668eb
to
18be0b9
Compare
OK, I think this is ready for review. This needs to be merged before the next release. "Interpolation Expression Sequence" is too long for the menu bar... Any ideas for an abbreviated name? Maybe just "Interpolations"? |
Unsure if adding this in where lexical goes (which I think is where it really belongs) is better than tacking on the end? Walter suggested here that the spec should be on its own page. I dislike that I had to bump all chapters up by 1. |
ping, this should go in before the release candidate is branched. |
// simple version of std.typecons.Tuple | ||
struct Tuple(T...) { T value; } | ||
Tuple!T tuple(T...)(T value) { return Tuple!T(value); } | ||
|
||
import core.interpolation; | ||
string name = "John Doe"; | ||
auto items = tuple(i"Hello, $(name), how are you?"); | ||
assert(items == tuple( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure the above lines can be simplified to:
alias AliasSeq(A...) = A;
import core.interpolation;
auto items = i"Hello, $(name), how are you?";
assert(items == AliasSeq!(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this works, I will simplify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... on second thought, this is doing something that I wasn't intending -- it's creating a compile-time sequence of things, including an alias to name
. What I really wanted was to show that the sequence is the same at runtime, e.g. what the list of values is. So I think I will leave it as-is.
The Tuple
type is needed because D doesn't let you return a value tuple directly.
$(D iq{) $(GLINK InterpolatedTokenStringTokens)$(OPT) $(D }) | ||
|
||
$(GNAME InterpolatedTokenStringTokens): | ||
$(GLINK InterpolatedTokenStringTokenNoBraces) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InterpolatedTokenStringTokenNoBraces is not defined. Here is a PR: #3772
See dlang/dmd#15715