Hello AST experts,
I'm implementing callables, as proposed in this pitch. The pitch introduces a new call
declaration for declaring callable methods: call
declarations are function-like, similar to the existing subscript
and init
declarations.
We're aware that adding a new declaration kind is controversial. But unless it's a non-starter due to insurmountable issues, we'd like to explore that design.
Implementation question: should the new CallDecl
inherit from FuncDecl
or AbstractFunctionDecl
?
Looking at other function-like declaration kinds: AccessorDecl
inherits from FuncDecl
, but ConstructorDecl
does not. (SubscriptDecl
is not really comparable: it inherits from AbstractStorageDecl
and contains AccessorDecl
s.)
The pro of conforming CallDecl
to FuncDecl
is code-sharing: there's no need to reimplement parts of SILGen/IRGen for CallDecl
.
However, FuncDecl
stores extra info unused by CallDecl
, which is not efficient.