Swift Macros: Understanding Freestanding & Attached Macros - QuickBird Studios
Have you ever started using a library and you were outraged by all the boilerplate code you need to write to make it work? Have you misused an API, because it wasn’t obvious to use? Have you thought that you just want to make some code just so much easier without all the manual work of writing complex code for all that repetitive logic? Well, there is a new Swift language feature to the rescue: Macros. We take a look at freestanding and attached macros and show you how they work. Macros allow packages to expose code generation functionality that you can use in your code, just like any other function or type. Maybe you have already used that new @Observablemacro for SwiftUI? Rather than having a type conform to ObservableObjectand then needing to put @Published in front of every single property that needs to be observed, you can now simply annotate a type with @Observable and that’s it. There’s a lot more to figure out about Swift Macros – let’s find out. With macros, you have quite a f
Swift Macros: Understanding Freestanding & Attached Macros FEBRUARY 19, 2024 | PAUL KRAFT Have you ever started using a library and you were outraged by all the boilerplate code you need to write to make it work? Have you misused an API, because it wasn’t obvious to use? Have you thought that you just want to make some code just so much easier without all the manual work of writing complex code for all that repetitive logic? Well, there is a new Swift language feature to the rescue: Macros. We take a look at freestanding and attached macros and show you how they work. Macros allow packag
Explore this link on the map →related reading
- Documentationdocs.swift.org
- Macros - The Rust Programming Languageweb.mit.edu
- Good examples of Clojure macros usage which demonstrate advantages of the language over the mainstream? - Stack Overflowstackoverflow.com
- Notes • Nick Arnernickarner.com
- SwiftUI by Example - free quick start tutorials for Swift developershackingwithswift.com
- A half-hour to learn Rustfasterthanli.me
- The power of subscripts in Swift | Swift by Sundellswiftbysundell.com
- Property wrappers in Swift | Swift by Sundellswiftbysundell.com
- Documentationdocs.swift.org
- Swift: From Protocol to AssociatedType then Type Erasure | Welcome to Monstarlab’s Engineering Blogengineering.monstar-lab.com
- Swift Protocol 背后的故事(Swift 5.6/5.7) | 雪峰的blogzxfcumtcs.github.io
- Rust Language Cheat Sheetcheats.rs