-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[docs] Describe the Curiously Recursive Inlinable Switch Pattern #22643
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
[docs] Describe the Curiously Recursive Inlinable Switch Pattern #22643
Conversation
@swift-ci Please smoke test |
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 for writing this up!
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.
LGTM!
|
||
Maintaining ABI compatibility with previously released versions of the standard library makes things more complicated. This section details some of the extra rules to remember and patterns to use. | ||
|
||
### The Curiously Recurring Inlinable Switch Pattern (CRISP) |
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.
### The Curiously Recurring Inlinable Switch Pattern (CRISP) | |
### The Curiously Recursive Inlinable Switch Pattern (CRISP) |
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.
It's a reference to the Curiously Recurring Template Pattern, but maybe it doesn't need to be.
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.
Either name is fine by me, but you've used the "Curiously Recursive Inlinable Switch Pattern" elsewhere (in the final paragraph of the section; and in the commit/PR title).
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.
Ooh, whoops, thanks! Okay then.
} | ||
``` | ||
|
||
Because `_roundSlowPath(_:)` isn't inlinable, the version of `round(_:)` that gets called at run time will always be the version implemented in the standard library dylib. And since FloatingPointRoundingRule is *also* defined in the standard library, we know it'll never be out of sync with this version of `round(_:)`. |
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.
Because `_roundSlowPath(_:)` isn't inlinable, the version of `round(_:)` that gets called at run time will always be the version implemented in the standard library dylib. And since FloatingPointRoundingRule is *also* defined in the standard library, we know it'll never be out of sync with this version of `round(_:)`. | |
Because `_roundSlowPath(_:)` isn't inlinable, the version of `round(_:)` that gets called at run time will always be the version implemented in the standard library dylib. And since `FloatingPointRoundingRule` is *also* defined in the standard library, we know it'll never be out of sync with this version of `round(_:)`. |
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.
Heh. My personal style is to not codefont type names, but I should defer to whatever the document is already doing.
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 like the document agrees with me ("AnyObject", "Strings").
19f3212
to
2c1201f
Compare
@swift-ci Please smoke test and merge |
@swift-ci Please smoke test |
@swift-ci Please smoke test Linux |
Adds a section to the Standard Library Programmer's Manual for resilience, along with the first entry about CRISP.
https://twitter.com/AirspeedSwift/status/1020449828717785089
https://twitter.com/UINT_MIN/status/1020503397357760512