So this is sneakily a proposal for direct
/indirect
. :-) I do have some questions/concerns:
-
Does directness + ownership fully capture the calling convention for all types, and are we sure that will be true in the future?
-
Will the compiler have to diagnose types that can't be passed directly? Up until now I think that hasn't been a Sema-level (roughly, "type-checking time") concept, and maybe it's still something that can be deferred to SIL diagnostics (roughly, "flow-sensitive diagnostics that run later in compilation than type-checking"). But I do worry about people trying to use
direct NonFrozenStruct
outside the original module and getting weird errors from the compiler, and I myself don't know whetherdirect Any
orindirect NSObject
are valid concepts or not. -
Having
@symbolName
without@cdecl
worries me: I think people will start exposing Swift functions to C [even more than they already do], and have things mostly work but then cause extremely weird errors in the corner cases. (But while@cdecl
isn't that much more work, it's a lot more than this…) -
The dlsym code is only correct if both sides use the same ABI, which could be a cause of weird issues on non-stable-ABI platforms if people don't think about it. But there is an unsafeBitCast there, so maybe it's ""fine"".