Multi-Part Method Names

In order to fit in well with the API conventions on the Cocoa platform, Iodine 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 Java 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 now supported on all platforms, and are also compatible with Oxygene, C# and Swift.

A multi-part method has parameter parts for each part, both when being declared:

boolean application(UIApplication application) didFinishLaunchingWithOptions(NSDictionary launchOptions) { ... }

and when being called:

myClass.application(myapp) didFinishLaunchingWithOptions(options);

Implementing Multi-Part Constructors

Iodine also allows you to call named and multi-part-named constructors defined externally, both from Cocoa APIs and on classes defined in Oxygene or Silver, and to declare your own. To avoid ambiguity, the syntax for this deviates sightly from Java's regular syntax for nameless constructors (which use the class's name), and uses the this keyword instead.

For example:

public class Foo
{
    public Foo(string name) // regular nameless Javaconstructor
    {
    }

    public this(string name) // same as above
    {
    }

    public this withName(string name) // regular named Java constructor
    {
    }

    public this withName(string name) andValue(object value) // multi-part Java constructor
    {
    }

}

These can be of course called as follows:

new Foo("Hello");
new Foo withName("Hello");
new Foo withName("Hello") andValue(42);

See Also