Why does @autoclosure go on the type, not the parameter?

It would be justified if something like this was possible:

func id<T>(_ it: T) -> T { it }
let getTen: @autoclosure () -> Int = id(10)
let ten: Int = getTen()
func id_(_ it: () -> ()) -> @autoclosure () -> () {
    return it()

Additionally, @ is used for attached macros, but I conceptualize (based on my experience in other languages) types as being more expression-like, so I'd expect the syntax to be #autoclosure(() -> Int) instead. Whereas an attached macro on a parameter (which is like a declaration, to me) would be intuitively reasonable.

1 Like

To clarify about the @/# thing, the logic here is that I've made a mental model where "# goes in expressions, @ goes on declarations" based on that being the rule for macros and the claim that existing @/#-based constructs should feel like macros do, and then I extrapolated this to parameters and types.

I understand that an #autoclosure macro wouldn't make sense because it doesn't require more compile-time or concrete syntax data.