Datatypes
THP requires that all datatypes start their name with an uppercase letter.
The following are basic datatypes.
Int
Same as php int
Int age = 32
// Hexadecimal numbers start with 0x
Int red = 0xff0000
// Octal numbers start with 0o
Int permissions = 0o775
// Binary numbers start with 0b
Int char_code = 0b01000110
// IMPORTANT!
// Since Octal starts with `0o`, using just a leading 0
// will result in a decimal!
Int not_octal = 032 // This is 32, not 26
thp
// TODO: Make it a compile error to have leading zeroes,
and force users to use 0o
for octal
Float
Same as php float
Float pi = 3.141592
Float light = 2.99e+8
thp
String
THP strings use only double quotes. Single quotes are used elsewhere.
String name = "Rose"
thp
Strings have interpolation with {}
.
print("Hello, {name}") // Hello, Rose
thp
Unlike PHP, THP strings are concatenated with ++
, not with .
.
This new operator implicitly converts any operator into a string.
val name = "John" ++ " " ++ "Doe"
val greeting = "My name is " ++ name ++ " and I'm " ++ 32 ++ " years old"
thp
The plus operator +
is reserved for numbers.
Bool
THP booleans are true
and false
. They are case sensitive,
only lowercase.
Bool is_true = true
Bool is_false = false
// This is a compile error
val invalid = TRUE
thp