Misc Functions

Additional utilities

proc compilerError(param msg: string ...?n)

Generate a compile-time error. The error text is a concatenation of the arguments.

proc compilerError(param msg: string ...?n, param errorDepth: int)

Generate a compile-time error. The error text is a concatenation of the string arguments.

Arguments:errorDepth -- controls the depth of the error stack trace
proc compilerWarning(param msg: string ...?n)

Generate a compile-time warning. The warning text is a concatenation of the arguments.

proc compilerWarning(param msg: string ...?n, param errorDepth: int)

Generate a compile-time warning. The warning text is a concatenation of the string arguments.

Arguments:errorDepth -- controls the depth of the error stack trace
proc compilerAssert(param test: bool)

Generate a compile-time error if the test argument is false.

proc compilerAssert(param test: bool, param errorDepth: int)

Generate a compile-time error if the test argument is false.

Arguments:errorDepth -- controls the depth of the error stack trace
proc compilerAssert(param test: bool, param msg: string ...?n)

Generate a compile-time error if the test argument is false. The warning text is a concatenation of the string arguments.

proc compilerAssert(param test: bool, param msg: string ...?n, param errorDepth: int)

Generate a compile-time error if the test argument is false. The warning text is a concatenation of the string arguments.

Arguments:errorDepth -- controls the depth of the error stack trace
proc min(x, y ...)

Compute the minimum value of 2 or more arguments using the < operator for comparison.

proc max(x, y ...)

Compute the maximum value of 2 or more arguments using the > operator for comparison.

proc exit(status: int)

Exit the program

Arguments:status -- The exit code for the program
proc isSubtype(type sub, type super) param

Returns true if the type sub is a subtype of the type super. In particular, returns true in any of these cases:

  • sub is the same type as super
  • sub is an instantiation of a generic type super
  • sub is a class type inheriting from super
  • sub is a type that coerces to super

Note that isSubtype(a,b) can also be written as a <= b or b >= a.

proc isProperSubtype(type sub, type super) param

Similar to isSubtype but returns false if sub and super refer to the same type.

Note that isProperSubtype(a,b) can also be written as a < b or b > a.

proc <(type a, type b) param
Returns:isProperSubtype(a,b)
proc <=(type a, type b) param
Returns:isSubtype(a,b)
proc >(type a, type b) param
Returns:isProperSubtype(b,a)
proc >=(type a, type b) param
Returns:isSubtype(b,a)