`@convention(c|block)` vs. `@[Function|Block]Pointer`

In (Apple) Swift, the distinction between a C function pointer and a stateful (objc) block pointer is made by:

@convention(c) (String) -> Int
// vs.
@convention(block) (String) -> Int

Whereas, in Silver, the docs (BlockPointer, FunctionPointer) imply that the distinction should be made by:

@BlockPointer public SomeBlock = (Int) -> (String); // E5 Attributes are not allowed here
// vs.												// E477 Declaration expected
@FunctionPointer public SomeFunc = (Int) -> (String);

Which, based on the errors should be:

@FunctionPointer public typealias SomeFunction = (String) -> Int
// vs.
@BlockPointer public typealias SomeBlock = (String) -> Int

However, as Oxygene uses native type modifiers method and block to distinguish these cases, and the Aspects are not possible to specify inline, Elements should use Swift’s native way to distinguish these cases.

we definitely should support be Swift ones, in Swift, yes. logging…

Thanks, logged as bugs://83065

I believe you do support them, but the docs do not mention them, while they do mention the Oxygene versions, and in fact what is shown in the Swift docs tab does not even compile as-is.

I’ll check. Thanx!

Thanks, logged as bugs://83066

bugs://83066 got closed with status fixed.

Yeah, that one just looks to be a docs issue/typo; both Xcode and our compiler do require the “typealias” keyword. Fixed.

Not as far as I can tell:

@convention(c) public typealias SomeBlock3 = (String) -> (Int); // E28 Unknown type "convention"
@convention(block) public typealias SomeBlock4 = (String) -> (Int); // E28 Unknown type "convention"

bugs://83065 should take care of that when done, in the mean time using @BlockPointer or @FunctionPointer is the best workaround (and those will keep working, as they are language-independent).

I don’t actually use Elements, I am just supporting an alternative implementation of Swift.

1 Like

Gotcha. the feedback is super appreciated, regardless! Thanx!