RemObjects Silver adds a few features to the Swift language to make it fit better on all the platforms it supports. We try to keep these extensions to a minimum, and tastefully within the design aesthetics of the Swift language.
Where additional keywords are needed, we follow the C-style language convention of prefixing these with two underscores ("
__") to avoid conflict with future changes to the official Swift language.
Exception handling is a crucial feature on the .NET and Java/Android platforms (and frankly, also comes in very handy on the Cocoa platform as well). Silver extends the Swift 2.0's error handling syntax to also support for exception handling on all platforms, as covered in more detail in the Exceptions and Error Handling topic.
Note: Silver 8.1 provided an interim syntax for exception handling that is being deprecated moving forward, for Silver 8.2 and later, in favor of the new
Partial Classes allow a single class (or struct) to be declared spanning multiple source files.
Static Classes are classes where all members are static. Silver provides a convenient shortcut to mark a class as static instead of having to mark each individual member.
Support for .NET-style multi-cast Events is provided to allow Swift code to fully participate in the .NET event system.
__await keyword is supported on .NET to unwrap asynchronous calls, similar to how
await works in Oxygene and C#. See the Await Expressions topic for more details.
Functions can be marked with the
__inline keyword to cause them to be inlined at the call site instead of being generated as separate functions in the executable. See the Inline Functions topic for more details.
RemObjects Silver has full support for Mapped Types, which are inlined types useful to create cross-platform wrappers with zero overhead. While you won't often implement your own mapped types, you will likely use existing ones, for example from the Sugar library.
Aspects are special attributes that influence how the compiler emits the final executable. In Silver they use regular Swift attributes syntax with the
@ symbol. Aspects are covered in more details in their own section, including how to use them and how to create your own.
New in Elements 9.3, the
__field keyword works symmetrical to
var to declare a field inside a class or struct. Unlike
var, the field will be implemented as plain low-level field, and not as property. This distinction can be important when, for example, dealing with Reflection on .NET.
- Not meant for user code, the
¡(inverted exclamation point) suffix operator can be used to mark a type as being nullable only if it is a reference type – essentially giving it the same Nullability behavior of the type name being used on its own in Oxygene or C#.
- Silver allows named parameters in attributes, as well as attribute scope prefixes using
__outcan be used similarly to
inout, but parameters will be one-directional.
- Silver supports the same Oxygene and C#, as well as a Swift-specific
@main:attribute prefix for applying attributes to the entry point.
- For symmetry with #available, a special
#defined()syntax is provided around the
defined()function for conditional compilation.
__field is new in Elements 9.3.