Language Extensions

RemObjects Mercury adds a few extra features to the Visual Basic™ language, in order to allow better interaction with all supported platforms and APIs, as well as tominteraxct with the other Elements languages.

Comments

In addition to ' and the REM keyword, Mercury also supports // to mark the rest of the current line as comment, and /* ... */ to mark a free-form block of code, potentially spanning multiple lines, as comment.

This change is additive to the Visual Basic™ language and should not cause incompatibility with existing code, where both // and /* are not valid constructs.

The // and /*...*/ comment styles are supported across all six Elements languages.

Extension Types

Extensions Types can be used to expand an existing type with new methods or properties.

Multi-Part Method Names

In order to fit in well with the API conventions on the Cocoa platform, Mercury adds support for multi-part method names — essentially the ability for a method's name to be split into separate parts, each followed by a distinct parameter. This feature is available on all platforms, and described in more detail in the Multi-part method names topic.

Lazy Properties

Lazy Properties are a special kind of property that will be initialized delayed, on first access.

Shared Classes

Entire classes, not just individual methods, can me marked as "Shared". Similar to a Module, a Shared class cannot be instantiated or descended from, and all its members implicitly become Shared and callable without an instance. However, unlike for modules, they do not become part of the global scope.

Dynamic

The Dynamic keyword is provided to represent an object of dynamic type. Any known member may be called on a Dynamic without compiler checks, and ther call will be dynamically dispatched at runtime, using Reflection or IDynamicObject).

Null

In addition to Nothing, which represents the default value or zero-representation of a given type ("unassigned" for reference types, "zero" for value types), Mercury also introduces the Null keyword, which represents a true null value, even for value types (much like null in C# or nil in Oxygene).

Pointers