-
Notifications
You must be signed in to change notification settings - Fork 447
buildExpression overload for ListBuilder proposal #2477
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
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.
Looks nice. Thank you!
Could you also add a short test case that uses this?
9551b50
to
0d6b731
Compare
Updated ✅ |
By the way, for some reason
|
0d6b731
to
a6197d8
Compare
Hmm, that's odd. It works for me. Have you tried after @keith's changes: #2484 |
Funny, looks like it depends on Terminal application (I'm using "Warp"). 🤯 But in "iTerm2" it seems everything works fine. ✅ |
(note my changes are unrelated unless you're using bazel) looks like you just needed a clean build |
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.
Thanks!
@swift-ci Please test |
So can the PR be merged now? 😃 |
@swift-ci Please test Windows |
Oh, sorry. Forgot about it. Thanks for the reminder. |
There is an overload in
ListBuilder
:This overload isn't a "standard" function for a
resultBuilder
to have. It's a convenience overload for the "swift-syntax" library. If it happens that our expression is already of typeFinalResult
, we can still use the same syntax without needing to handle this scenario separately. I stumbled upon this overload accidentally while working on my pet project when was surprised to find that my code still compiles. So, yes, it's quite convenient.In this PR, I propose adding one more
buildExpression
overload for convenience:Its purpose is similar to the function:
It allows to build arrays. While the above function facilitates array building using the
for ... in ...
syntax, the overload I propose enables array building using result of.map { }
expression.It has always felt strange to me that "standard"
resultBuilders
work withfor ... in ...
but not with.map { }
. It seems counterintuitive. Personally, I prefer the.map { }
syntax overfor ... in ...
. I believe it would be beneficial to allow developers to use both syntaxes when working withresultBuilders
.This proposal is additive and has no impact on existing source code.