If

The If aspects can be attached to types and members in order to conditionally include or exclude them from compilation.

This is equivalent to surrounding the code by a more traditional Conditional Compilation directive such as {$IF}/#if, but results in cleaner code (similar to how the new if defined() system function is encouraged to be used inside code blocks).

The aspect takes a single Boolean expression that must be constant or determinable at compile-time.

Most commonly, it would be used in combination with defined() to check for one or more conditional defines (e.g. "DEBUG"). Complex expressions and combination of multiple calls to defined() or exists() are permissible, as long as the entire expression can be reduced to true or false at compile-time.

The type or member that the aspect is applied to will only be compiled into the final executable if the define in question is, in fact, defined.

[If(defined("COCOA") or defined("ISLAND"))]
method Foo;
begin
end;
[If(defined("COCOA") or defined("ISLAND"))]
public void Foo()
{
}
@If(defined("COCOA") or defined("ISLAND"))
public func Foo() {
}
@If(defined("COCOA") or defined("ISLAND"))
public void Foo() {
}

Defined by the core compiler.

See Also