When should thin or unified be used on closures?

I am using closures as struct parameters. As these closures typically are defined on top level in my case, I omitted further specification in the struct definition:

def fun() -> Int:
    return 42

struct S[fun: def() -> Int]:
    pass

Now I get the warning “omitting ‘thin’ in function types is deprecated; specify ‘capturing’, ‘unified’, or ‘thin’”. Specifying thin seems to do the trick. However, the name unified suggests that this closure type should work as well. This is not the case for top level functions.

Which type should be used when? unified for capturing / non-toplevel functions and thin else?

2 Likes

I have the same question and just realised why I don’t know the answer, there doesn’t seem to be a proposal for unified closures.

For your use case I think thin is appropriate. Syntax changes will be accompanied by documentation and released soon.

2 Likes