# \`@isolated(any)\` function types

**URL:** <https://forums.swift.org/t/isolated-any-function-types/70562>\
**Category:** Pitches\
**Tags:** concurrency, actors\
**Created:** [March 10, 2024, 11:22pm UTC](https://forums.swift.org/t/isolated-any-function-types/70562 "2024-03-10T23:22:40Z")\
**Posts on this page:** 1\
**Showing post:** 29

<div class="post-metadata">

**Author:** ![cal](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/cal/32/35557_2.png) [@cal](https://forums.swift.org/u/cal)\
**Post date:** [March 16, 2024, 4:23pm UTC](https://forums.swift.org/t/isolated-any-function-types/70562/29 "2024-03-16T16:23:55Z")

</div>

Some comments on the syntax in this example:

```swift
func delay(operation: @isolated(any) () -> ()) {
  let isolation = operation.isolation
  Task { [isolated isolation] in
    print("waking")
    operation() // <-- does not cross an isolation barrier and so is synchronous
    print("finished")
  }
}

```

It's _really great_ that this will be possible!

Could it make sense to also use the `@isolated` annotation to support applying an explicit isolation to a closure? That could let us simplify this example to:

```swift
func delay(operation: @isolated(any) () -> ()) {
  Task { @isolated(operation) in // seems very elegant!
    // ...
  }
}

```

I find this spelling really appealing because it's more similar to the syntax for isolating a closure to a global actor (both would use an @ annotation: `@MainActor in` and `@isolated(myActor) in`).

e.g. in this example from earlier, I'd find `@isolated(counter)` to be more intuitive and appealing:

> [@cal](#):
>
> ```swift
> Task { [isolation counter] in
> counter.incrementAndAssertCountEquals(iteration)
> }
> 
> ```

vs

```swift
Task { @isolated(counter) in
  counter.incrementAndAssertCountEquals(iteration)
}

```

---

_[View the full topic](https://forums.swift.org/t/isolated-any-function-types/70562)._
