Multi-Part Method Names
In order to fit in well with the API conventions on the Cocoa platform, Mercury method syntax has been expanded with support for what we call multi-part method names.
Multi-part method names are essentially the ability for a method's name to be split into separate parts, each followed by a distinct parameter. This is "required" on the Cocoa platform, because all the platform's APIs follow this convention, and we wanted Mercury to be able to both consume and implement methods alongside those conventions without resorting to awkward attributes or other adornments, and to feel at home on the Cocoa platform.
For cross-platform completeness, multi-part method names are supported on all platforms, and are also compatible with Oxygene, C#, Swift and Java.
A multi-part method has parameter parts for each part, both when being declared:
Sub application(application As UIApplication, didFinishLaunchingWithOptions launchOptions As NSDictionary) ...
and when being called:
myClass.application(myapp, didFinishLaunchingWithOptions: options);
Named & Multi-Part Constructors
Mercury also allows declaring and calling named constructors with (optionally) multiple name parts.
For example:
Public Class Foo
{
Public Sub New(name As String) ' regular nameless constructor
...
End Sub
Public Sub New withName(name As String) ' regular named constructor
...
End Sub
Public Sub New withName(name As String, andValue value As Object) ' multi-part constructor
...
End Sub
End Class
These can be of course called as follows:
New Foo("Hello")
New Foo withName("Hello")
New Foo withName("Hello", andValue: 42)