Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yume190/temporaryvariable
`TemporaryVariable` provide a macro `#info {...}`. It capture most function calls and assign them to temporary variables.
https://github.com/yume190/temporaryvariable
swift swiftmacros
Last synced: 11 days ago
JSON representation
`TemporaryVariable` provide a macro `#info {...}`. It capture most function calls and assign them to temporary variables.
- Host: GitHub
- URL: https://github.com/yume190/temporaryvariable
- Owner: yume190
- License: mit
- Created: 2023-07-20T09:26:22.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-12-29T03:44:13.000Z (about 1 year ago)
- Last Synced: 2023-12-29T04:42:45.526Z (about 1 year ago)
- Topics: swift, swiftmacros
- Language: Swift
- Homepage:
- Size: 15.6 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TemporaryVariable
---
`TemporaryVariable` provide a macro `#info {...}`. It capture most function calls and assign them to temporary variables.
### Usage
Most of the time we will write the following code.
```swift
func test() -> Int {
return x()
}
```Usually we need a temporary variable to facilitate our debugging
```swift
func test() -> Int {
let result = x()
return result
}
```Now. You can use `#info {...}`
```swift
import TemporaryVariable
func test() -> Int {
#info {
return x()
}
}
```The expanded code
```swift
import TemporaryVariable
// public func info(_ closure: () -> T) -> T {
// return closure()
// }func test() -> Int {
info {
let __macro_local_7result0fMu_ = x()
return __macro_local_7result0fMu_
}
}
```