Skip to content

Commit

Permalink
-iOS: new WWDC23 video {'Generalize APIs with parameter packs'}.
Browse files Browse the repository at this point in the history
  • Loading branch information
XLE22 committed Sep 20, 2023
1 parent 1545753 commit b89fe03
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/assets/json/en/ios/wwdc/ios-wwdc-listnota11y.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
"raccourcis": "",
"profils": ["All","Accessibility","Dark Mode","Debugging","DocC","Formatting","Instruments","Keyboard","Keynote","Localization","Optimization","Platforms State...","Regex","Shortcuts","Swift","Swift Playgrounds","SwiftUI","What's new in...","Xcode"]
},
{
"themes": "WWDC 2023",
"title": "Generalize APIs with parameter packs",
"type": [],
"tests": [],
"verifier": [],
"resultat": [],
"exception": "",
"raccourcis": "2023/2310168",
"profils": ["All","Swift"]
},
{
"themes": "WWDC 2023",
"title": "Keynote",
Expand Down
Binary file added src/en/mobile/images/iOSdev/wwdc23-10168_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/en/mobile/images/iOSdev/wwdc23-10168_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/en/mobile/images/iOSdev/wwdc23-10168_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/en/mobile/images/iOSdev/wwdc23-10168_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/en/mobile/images/iOSdev/wwdc23-10168_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/en/mobile/images/iOSdev/wwdc23-10168_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/en/mobile/images/iOSdev/wwdc23-10168_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/en/mobile/images/iOSdev/wwdc23-10168_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/en/mobile/images/iOSdev/wwdc23-10168_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions src/en/mobile/ios/wwdc/nota11y/2023/2310168.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title : "Generalize APIs with parameter packs"
abstract: "Abstract over types as well as the number of arguments in generic code."

displayToc: true
---

# WWDC 2023: Generalize APIs with parameter packs
Find hereafter a detailed summary of a video that belongs to a [taxonomy of some WWDC footages](../../).

The original video is available on the **Apple official website** ([session 10168](https://developer.apple.com/videos/play/wwdc2023/10168/)).
![](../../../../../images/iOSdev/wwdc23-10168_Poster.png)
"Swift parameter packs are a powerful tool to expand what is possible in your generic code while also enabling you to simplify common generic patterns. We'll show you how to **abstract over types as well as the number of arguments in generic code** and simplify common generic patterns to avoid overloads."
</br>Hereafter, the underlined elements lead directly to the playback of the WWDC video at the appropriate moment.
</br>

## [The&nbsp;origins](https://developer.apple.com/videos/play/wwdc2023/10168/?time=51)
![](../../../../../images/iOSdev/wwdc23-10168_1.png)

Regarding a [client&nbsp;server&nbsp;example](https://developer.apple.com/videos/play/wwdc2023/10168/?time=124), the number of query arguments may be too large according to the needs.

![](../../../../../images/iOSdev/wwdc23-10168_2.png)

However, this problem might be partially solved while using the [variadic&nbsp;parameters](https://developer.apple.com/videos/play/wwdc2023/10168?time=136) combined with the [type&nbsp;erasure](https://developer.apple.com/videos/play/wwdc2023/10168?time=172) notion that give rise to some [limitations](https://developer.apple.com/videos/play/wwdc2023/10168?time=154) though.

![](../../../../../images/iOSdev/wwdc23-10168_3.png)
This kind of situation is typically what **[parameter&nbsp;packs](https://developer.apple.com/videos/play/wwdc2023/10168?time=237)** are for.
</br>

## [The&nbsp;fundamentals](https://developer.apple.com/videos/play/wwdc2023/10168/?time=248)

'A **parameter pack** can hold any quantity of types or values and pack them together to pass them as an argument to a function.'
![](../../../../../images/iOSdev/wwdc23-10168_4.png)

Handling packs at the **type-level** is a [major&nbsp;difference](https://developer.apple.com/videos/play/wwdc2023/10168/?time=358) with the usual collections thanks to new ways for [writing&nbsp;code](https://developer.apple.com/videos/play/wwdc2023/10168/?time=376).

![](../../../../../images/iOSdev/wwdc23-10168_5.png)

It comes in handy to [avoid&nbsp;boilerplate&nbsp;code](https://developer.apple.com/videos/play/wwdc2023/10168/?time=513) in such situations...
![](../../../../../images/iOSdev/wwdc23-10168_6.png)

...while easily tailoring the [generic&nbsp;requirements](https://developer.apple.com/videos/play/wwdc2023/10168/?time=655) on packs as well.
![](../../../../../images/iOSdev/wwdc23-10168_7.png)
</br>

## [Implementation](https://developer.apple.com/videos/play/wwdc2023/10168/?time=732)
It's recommended the **parentheses be used** for wrapping the pattern expression when the results are embedded in a tuple.

![](../../../../../images/iOSdev/wwdc23-10168_8.png)

Regarding the [initial&nbsp;example](#the-origins), if the **[input and output types need to be different](https://developer.apple.com/videos/play/wwdc2023/10168/?time=871)**, the code writing may be changed to tailor the parameter pack concept while improving the [flow&nbsp;control](https://developer.apple.com/videos/play/wwdc2023/10168/?time=1013) with the `do-catch` statement for **handling errors**.

![](../../../../../images/iOSdev/wwdc23-10168_9.png)

</br>
1 change: 1 addition & 0 deletions src/en/mobile/ios/wwdc/nota11y/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The videos that may be of interest to **designers** are highlighted with a **ded

<section class="visually-hidden" id="wwdcTests" aria-hidden="true">
<h2 id="hhwwdc2023" class="pt-5">WWDC 2023</h2>
<p id="hwwdc67">WWDC 2023 Generalize APIs with parameter packs</p>
<p id="hwwdc66">WWDC 2023 Keynote</p>
<p id="hwwdc65">WWDC 2023 Platforms State of the Union</p>
<p id="hwwdc64">WWDC 2023 Unleash the UIKit trait system</p>
Expand Down

0 comments on commit b89fe03

Please sign in to comment.