Notice: Stat is currently in private beta. This documentation is incomplete and subject to change.

Stat Docs

Constant Values

There are only a few constants in the Stat programming language. These values are built-in, available everywhere, and never change. They also take priority over variables that are named the same as them. Here is a quick list of all the constants available in Stat:
  • empty - The empty value. This is synonymous to null in other languages and means that there is no value.
    • The data type for this value is: empty
  • true - The boolean true value. This is not the same as the integer value: 1
    • The data type for this value is bool
  • false - The boolean false value. This is not the same as the integer value: 0
    • The data type for this value is bool
  • infinity - The maximum integer value. This is a constant used to represent an infinite integer.
    • The data type for this value is int
  • -infinity - The minimum integer value. This is a constant used to represent a negative infinite integer.
    • The data type for this value is int
Here are some code examples:
MAIN
	let noVal = empty
	let trueVal = true
	let falseVal = false
	let infVal = infinity
	let negInfVal = -infinity

empty

You can set an optional variable to an empty state by setting the value of the variable to empty. In order to specify that a variable is optional, you must add an optional type hint... which is a type hint that has a question mark ? appended to it.
MAIN
	// maybeAge will contain an integer value of 22
	let maybeAge: int? = 22

	// After this statement, maybeAge will contain
	// no value at all. Not even zero.
	maybeAge = empty

true and false

true and false are the only two boolean values in Stat and they are both constants. In most cases, they will be used as a condition to determine whether or not to execute a branch of code.
IMPORTS
	doSomething

MAIN
	let doIt = true

	if doIt
		doSomething()
That previous code example doesn't really have any choice. doSomething() is always executed because the value stored in doIt is always true. In reality, what you'll most likely do is code comparisons that evaluate to either true or false at runtime, or you'll specify that an argument to a function is a bool type and you'll use that to determine if a branch should execute.
Here is a code example of a function that takes a bool value as an argument and calls a function if that value is true
IMPORTS
	doSomething

META
	type function
	arg doIt: bool
	return: bool

FUNCTION
	if doIt
		// This will execute if doIt is true
		doSomething()

	// Since this function is required to return a bool, we are
	// simply returning the same boolean that was passed in.
	return doIt
Here is a code example of a function that takes an int value as an argument and returns true if that argument is 21 or larger, otherwise, it returns false. Although we are not using a constant of true or false in the return value, we are dynamically generating a bool value at runtime.
META
	type function
	arg age: int
	return: bool

FUNCTION
	// This is a comparison expression that evaluates to
	// either true or false depending on the value of age
	return age >= 21

The infinities

In Stat, there are 2 constants available that represent both extremes of the integer spectrum. infinity and -infinity. infinity (positive infinity) is larger than any other numeric value. While -infinity (negative infinity) is smaller than any other numeric value.

 Something to note

In Stat, both infinity and -infinity have a data type of int. They are both integer values. Although they can be compared to fractions, they are not fractions.
Here are some code examples that details how both the infinities behave
MAIN
	let max = infinity
	max += 1
	// max is still infinity
	max -= 1
	// max is still infinity
	max *= infinity
	// max is still infinity

	// This will also equal infinity
	max = -infinity * -infinity

	// This will also equal infinity
	max = 1 / 0

	// This will also equal infinity
	max = 10 ** infinity

	// This will also equal infinity because
	// infinity is considered an even number in Stat
	max = -10 ** infinity

	// This will equal 0
	let zero = 1 / infinity

	// This will also equal 0
	zero = 10 ** -infinity

	let min = -infinity
	min -= 1
	// min is still -infinity
	min += 1
	// min is still -infinity
	min *= infinity
	// min is still -infinity

	// This will also equal -infinity
	min = infinity * -infinity

	// This will also equal -infinity
	min = -1 / 0

 Something to note

In Stat, both infinity and -infinity are considered even numbers. So taking any negative number less than 1 to the power of infinity will equal positive infinity
Previous
Next