Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
static lazy varの挙動を追ってみた
Search
noppefoxwolf
May 31, 2018
Technology
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
static lazy varの挙動を追ってみた
noppefoxwolf
May 31, 2018
More Decks by noppefoxwolf
See All by noppefoxwolf
柔軟性のあるUIで、多くの環境でアプリを活躍させる/iOSDC26
noppefoxwolf
0
1.6k
High performance GIF playback/iOSDC25
noppefoxwolf
1
700
Spice up your notifications/try!Swift25
noppefoxwolf
3
860
iOSの隠されたAPIを解明し、開発効率を向上させる方法/iOSDC24
noppefoxwolf
2
1.5k
今から理解するApp Intentエコシステム/WWDC24Recap
noppefoxwolf
0
84
既存アプリをvisionOS対応してリリースした話/visionOS LT vol5
noppefoxwolf
0
240
UIのブラックボックスを探る/iOSDC23
noppefoxwolf
3
5.2k
CoreGraphicsでドット絵を描こう/iOSDC22
noppefoxwolf
0
3.3k
ランタイムデバッグのススメ/iOSDC21
noppefoxwolf
1
5.8k
Other Decks in Technology
See All in Technology
しろおびから始める!ログ活用の第一歩
shumei_ito
0
950
大型犬好きによるPugの紹介
yamanoku
1
160
⾮構造化データを価値に変える AI エージェント基盤とその組織
ivry_presentationmaterials
0
190
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
5
1.1k
QA4AI 2026-Oct 生成AI時代の品質保証
tokuty
1
890
S3 Filesで挑む! 八戸せんべい汁の食べ頃問題
usanchuu
0
110
DBについての基礎説明(MySQL編) - コロプラ 2026年度 新卒研修
colopl
0
110
Tofu-Controller lightning talk @ Containerday 2026
gionn
0
120
FinOps Agentが生んだ技術負債:コスト自動調査の落とし穴と解消までの道のり
oasis1994liveforever
1
120
コンテナ運用におけるネットワーク・コンテナコストの削減方法/How to Reduce Network and Container Costs in Container Operations
masakiokuda
1
280
[JAWS-UG彩の国埼玉#12]そろそろ準備する?re:Invent2026をやさしく解説 / reinvent2026-sainokuni
sh_fk2
1
350
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
2
290
Featured
See All Featured
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
520
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
30 Presentation Tips
portentint
PRO
1
430
Skip the Path - Find Your Career Trail
mkilby
1
260
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
490
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Navigating Weather and Climate Data
rabernat
0
560
Docker and Python
trallard
47
4.2k
So, you think you're a good person
axbom
PRO
2
2.2k
Transcript
TUBUJDMB[ZWBSƑ㌀ọƵሔƆƉ ƢƂ ့ழ္ ! !OPQQFGPYXPMG
MB[ZƑŭŸƬŧ lazy var value: Int = 0 WBMVFƒƸDžǑǏŸƯƮơƊളӮŸƯƍŧ ! !OPQQFGPYXPMG
USZ4XJGUƊƑǜDžǡǙDž lazy var value: Int = { preconditionFailure() }() Ԛ௹߄с⇜ƍǭȃǧǜƹƵMB[ZWBSƊ࿆żƮŶƋ
ƊaսೆభƎƸDžǑǏżƮƋઋƋżŶƋůƊŰƮb ơƂ/FWFSƊْżŶƋƊƵƲŽƎ࿆ƊŰƮb ! !OPQQFGPYXPMG
TUBUJDඔƑMB[ZWBS UVUPSJBMTXJGU class Class { static lazy var value: Int
= { preconditionFailure() }() } Class.value = 1 ! !OPQQFGPYXPMG
$ swiftc tutorial001.swift tutorial001.swift:2:10: error: 'lazy' must not be used
on an already-lazy global static lazy var value: Int = { preconditionFailure() }() ^~~~~ MB[ZNVTUOPUCFVTFEPOBOBMSFBEZMB[Z HMPCBM wHMPCBMඔƒ࠻ƎMB[ZƃŮƬaMB[ZŧƬƍŧƫ ! x ! !OPQQFGPYXPMG
UVUPSJBMTXJGU class Class { static var value: Int = {
preconditionFailure() }() } Class.value = 1 MB[ZƵຓźƉljȉǧƺȁƥӮۿĆ ! !OPQQFGPYXPMG
$./tutorial002 Fatal error: file tutorial002.swift, line 2 ༵ƎQSFDPOEJUJPO'BJMVSFůޫƓƯƉŧƮl ! !OPQQFGPYXPMG
Ệ㗈 YYYYYTXJGU class Class { static var xxxxx: Int =
{ preconditionFailure() }() } ඔƵƲŮƭƧżŲYYYYƎźƉ4*-Ƶԛ৯źƉƢƮ 4XJGU*OUFSNFEJBUF-BOHVBHF4XJGUƑᇏᾇ∽ ! !OPQQFGPYXPMG
! !OPQQFGPYXPMG
TXJGUDFNJUTJMHFOYYYYYTXJGUYYYYYTJM ! !OPQQFGPYXPMG
// static Class.xxxxx.setter sil hidden [transparent] @_T05xxxxx5ClassCAASivsZ : $@convention(method) (Int,
@thick Class.Type) -> () { // %0 // users: %8, %2 // %1 // user: %3 bb0(%0 : $Int, %1 : $@thick Class.Type): debug_value %0 : $Int, let, name "value", argno 1 // id: %2 debug_value %1 : $@thick Class.Type, let, name "self", argno 2 // id: %3 // function_ref Class.xxxxx.unsafeMutableAddressor %4 = function_ref @_T05xxxxx5ClassCAASivau : $@convention(thin) () -> Builtin.RawPointer // user: %5 %5 = apply %4() : $@convention(thin) () -> Builtin.RawPointer // user: %6 %6 = pointer_to_address %5 : $Builtin.RawPointer to [strict] $*Int // user: %7 %7 = begin_access [modify] [dynamic] %6 : $*Int // users: %9, %8 assign %0 to %7 : $*Int // id: %8 end_access %7 : $*Int // id: %9 %10 = tuple () // user: %11 return %10 : $() // id: %11 } // end sil function '_T05xxxxx5ClassCAASivsZ' %4 ~ %5 ॳظԽ %6 ~ %7 ೖ ! !OPQQFGPYXPMG
%4 = function_ref @_T05xxxxx5ClassCAASivau : $@convention(thin) () -> Builtin.RawPointer //
user: %5 %5 = apply %4() : $@convention(thin) () -> Builtin.RawPointer // user: %6 GVODUJPO@SFGTJMGVODUJPOOBNFTJMUZQF4*-倔ඔ ƛƑҕᅶƵቔӮ @5YYYYY$MBTT$""4JWBVč䴙ƆƉŧŲƋ QSFDPOEJUJPO'BJMVSFĎƑҕᅶቔӮ BQQMZƊ⻎ྛ ! !OPQQFGPYXPMG
սೆభƎQSFDPOEJUJPO'BJMVSFůޫƓƯƉŧƮƑƒ ⻎ ! !OPQQFGPYXPMG
IUUQTCVHTTXJGUPSHCSPXTF43 ! !OPQQFGPYXPMG
'lazy' must not be used on an already- lazy global
MB[Z䵐۬ₑǭȃǧǜƹƑMB[ZƋƒũၩ ! !OPQQFGPYXPMG