On platforms that support more than one Object Model, the modelOf system function returns a string value describing the object model of the passed type, currently one of Island, Cocoa, Swift or COM.

modelOf() accepts as its single parameter the name of a specific type know at compile time or a generic type parameter in scope.

As a special use case, if modelOf() is used in a [case]/switch statement inside a generic, the compiler will collapse the case statement so that at runtime, only the case specific to the current object model will execute without overhead, for any given concrete instantiation of the generic type.

  ImmutableList<T> = public class(IEnumerable<T>, ICollection)
    where T is unconstrained;


    method IsEqual(Item1, Item2: T): Boolean;
      case modelOf(T) of
        "Island": exit (Item1 as IslandObject).Equals(Item2 as IslandObject);
        "Cocoa": exit (Item1 as CocoaObject).isEqualTo(Item2 as CocoaObject);
        "Swift": exit (Item1 as SwiftObject).Equals(Item2 as SwiftObject);
        else raise new Exception($"Unexpected objetc model {modelOf(T)}");

See Also