[swift-corelibs-dev] Swift Shims
Fernando RodrÃguez
fernando at agbo.biz
Thu Aug 4 13:27:01 CDT 2016
Thanks, cristal clear! :-)
On August 3, 2016 at 9:51:38 PM, Brent Royal-Gordon (brent at architechies.com)
wrote:
> On Aug 3, 2016, at 8:39 PM, Fernando RodrÃguez via swift-corelibs-dev <
swift-corelibs-dev at swift.org> wrote:
>
> I'm having some trouble understanding what on Earth SwiftShims are. The
name probably makes it obvious to native English speakers, but it's not
helping me...
>
> Could someone please enlighten me?
"Shim" is a relatively common programming term; it means a lightweight
compatibility layer which corrects for differences between platforms. For
instance, if you're supporting three different OSes with three different
random number calls, you might write a `randomNumber()` shim function which
calls whichever one is correct for that platform.
(Outside of programming, a "shim" is a thin piece of material, often wood,
which you put under the leg of a piece of furniture if it's crooked or
wobbly.)
SwiftShims specifically contains functions written in C, C++, or
Objective-C++ which the Swift standard library's internals need to call.
These functions often translate the parameter types of calls into forms
which are easier to call from Swift, or fill in functionality that's
missing on certain platforms. For instance, the I/O in the standard
library's `readLine()` function is handled by a C++ function called
`swift_stdlib_readLine_stdin()`. That function is part of SwiftShims; on
most platforms, it calls through to a C standard library `getline()`
function, but on a few it emulates that function's behavior.
Unless you're working on the standard library (or Foundation, which I
believe uses a couple of SwiftShims calls), you shouldn't ever interact
with or care about SwiftShims. It's a private implementation detail of
Swift.
--
Brent Royal-Gordon
Architechies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20160804/6011ce16/attachment.html>
More information about the swift-corelibs-dev
mailing list