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. If one of the arguments isMath.NAN
, the result is also NAN.
-
proc
max
(x, y ...)¶ Compute the maximum value of 2 or more arguments using the
>
operator for comparison. If one of the arguments isMath.NAN
, the result is also NAN.
-
proc
exit
(status: int)¶ Exit the program
Arguments: status – The exit code for the program
-
proc
isCoercible
(type from, type to) param¶ Returns true if the type from is coercible to the type to, or if
isSubtype(from, to)
would return true.
-
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
Note that
isSubtype(a,b)
can also be written asa <= b
orb >= 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 asa < b
orb > 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)