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

Make c++ defer looks like a swift one #166

Merged
merged 1 commit into from Dec 6, 2015
Merged

Make c++ defer looks like a swift one #166

merged 1 commit into from Dec 6, 2015

Conversation

przybylski
Copy link
Contributor

This code uses some c++ trickery to make defer macro looks almost like defer keyword in swift.

Instad of:

defer([&]() {
  /* cleanup code */
});

coders can now drop some boilerplate and do this:

defer {
  /* cleanup code */
};

But this changes capture list to all values by reference

@nadavrot
Copy link
Contributor

nadavrot commented Dec 4, 2015

@przybylski , please find the author of this code (using git blame) and invite them to review this code (by using their github handle name)

@przybylski
Copy link
Contributor Author

@lattner could you have a look on this PR?

@jckarter
Copy link
Member

jckarter commented Dec 4, 2015

I prefer the function to macro trickery, honestly. Neat trick though.

lattner added a commit that referenced this pull request Dec 6, 2015
Make c++ defer looks like a swift one
@lattner lattner merged commit 82a0067 into apple:master Dec 6, 2015
@lattner
Copy link
Collaborator

lattner commented Dec 6, 2015

Simultaneously cute and horrible :-) - looks great, thanks!

slavapestov pushed a commit to slavapestov/swift that referenced this pull request Nov 27, 2018
handle EWOULDBLOCK error in _dispatch_operation_perform
slavapestov pushed a commit to slavapestov/swift that referenced this pull request Nov 27, 2018
handle EWOULDBLOCK error in _dispatch_operation_perform

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
dabelknap pushed a commit to dabelknap/swift that referenced this pull request Dec 5, 2018
Add support for deinitializers
maldahleh pushed a commit to maldahleh/swift that referenced this pull request Oct 26, 2020
Add a change log describing the changes since the Swift 5.1 release
freak4pc pushed a commit to freak4pc/swift that referenced this pull request Sep 28, 2022
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

4 participants