Variable personalities
Short introduction
- string
- char
- number
- infinity
- boolean
- true
- false
- big
- pbig
- nbig
- int
- u64
- i64
- float
- list
- errnumber
blah blah
Below is a complete list of all the variable personalities in Wing.
string
is the base personality of all variables in Wing. All variables have the string
personalities, and all personalities extend from string
.Hello world
is a variable that has only the string
personality.char
is a subset of string
. It represents a single character within a string
.W
is a char
, and also a string
(since personalities are inherited from parents). It is possible to get a char
from a string
, for example with the following code:$var = Hello
$letter = 0
$letter < item $var 0
print $letter -- This will display "H"
list_personalities letter -- This will display "char, string"
number
is a personality that designates all variables that can be used against mathematical operations without returning a variable with the errnumber
personality.43
is a number
, -39
is a number
, 3.14159
is a number
, inf
is also a number
(see infinity
).Variables with the
number
personality generaly have additional child personalities (e.g. int
) to better specify the exact type of number they contain.list
is a personality for variables that hold multiple values. The values the list
contains can have different personalities, and special operations can be run only on list
variables. list
variables can be compared to arrays in other programming languages.Due to the fact the
list
personality is inherited from string
, all list
variables have a string
representation, which looks like this: [List 'e475bf4f-b5d5-430f-9413-bf7825354fdd']
. It is also possible to copy a reference to a specific list
variable, using the following code:$l1 = 0
$l2 = 0
$l1 < list
$l2 = $l1
print $l1 $l2 -- You can see that both $l1 and $l2 point to the same 'list'
To work around this behavior, it is possible to make a copy of the
list
variable itself instead:$l1 = 0
$l2 = 0
$l1 < list
$l2 < listcopy $l1
print $l1 $l2 -- You can now see that $l1 and $l2 point to different 'list's
errnumber
is a special variable personality that designates a variable that was intended to be a number
but cannot because of an error.This could be, for example, trying to do the sum of variables that do not have the
number
personality. The errnumber
personality is represented as a string
as NaN
.infinity
, in general, designates all numbers that are infinite. This includes the infinity notation (∞) and may include other numbers. Note that non-real numbers (for example roots of negative numbers) are represented as errnumber
instead.infinity
variables are represented as inf
in a string
form.boolean
are binary values that can be either true
or false
. The boolean
personality alone is never used.true
is a value that is considered a logical yes, and a binary 1. The u64
, int
, number
and string
representation of true
is 1
.Note, however, that
-1
is not considered a boolean. Only natural integer 1
is considered a boolean.false
is a value that is considered a logical no, and a binary 0. The u64
, int
, number
and string
representation of false
is 0
.big
is a subset of number for all numbers that are bigger than the maximum 64-bit integer length. They can contain as many digits as storage permit. Note, however, that they cannot be used for regular mathematical operations due to their differences with regular int
or float
values.pbig
is a positive big
number
. 1234567890123456789
is a pbig
value.nbig
is a negative big
number
. -1234567890123456789
is an nbig
value.int
is a number
that does not contain decimals. An int can be either signed (i64
) or unsigned (u64
). All int
values are coded on 64-bit due to Wing running only on 64-bit platforms.u64
is an unsigned int
. That is, an int
that does not contain a sign. 0
is considered an u64
value as well.i64
is a signed int
, it contains a sign. In most cases, this means the value is negative (e.g. -5
). It is worth noting that signed int
values take up more memory than unsigned int
values.float
values are numbers that contain decimals. Again, they are coded on 64-bit, meaning their total value (including what is before and after the decimal point) must not exceed that of a 64-bit integer.