Skip to main content

Data Types

TinyPanda is dynamically typed. You do not declare variable types; types belong to the values. A single variable can hold any type of data and switch types freely over its lifecycle.

bamboo msg = "I am a string!"; // Starts as a String
msg = 42; // Changes to an Integer
msg = 9.99; // Changes to a Float
msg = true; // Changes to a Boolean

TinyPanda supports these following fundamental data types:

Strings

Textual data wrapped in double quotes ("...").

TinyPanda only supports double quotes. Single quotes ('...') will cause a syntax error.

bamboo name = "Panda";
whatIs(name) // Outputs: STRING

Check out all available string builtins here.

Escape Characters

TinyPanda strings support special character combinations starting with a backslash \ to format your console output, while forward slashes / print normally as raw text.

TinyPanda supports two escape characters:

  • \n: Adds a new line in the string.
  • \t: Adds a tab space in the string.
echoln("Hello\tTinyPanda!");
echoln("We are reading\nTinypanda Docs.");
// Outputs:
// Hello TinyPanda!
// We are reading
// TinyPanda Docs.

Integers

Whole numbers (positive, negative, or zero) without decimals.

bamboo age = 22;
bamboo temperature = -5;

Floats

Numbers containing a fractional part or a decimal point. This allows TinyPanda to handle precise continuous measurements or mathematical constants.

bamboo pi = 3.14159;
bamboo price = 99.95;
bamboo negativeFloat = -0.75;

Booleans

Logical truth values: either true or false.

bamboo isHungry = true;

Lists

List in TinyPanda are ordered, dynamic collections of values. List are used to store a bunch of items together in one place. Think of them as a collection container.

Creating a List

Lists are initialized using square brackets [...] with elements separated by commas ,. You can assign them to identifiers using the bamboo keyword just like any other data type:

bamboo numbers = [10, 20, 30];
bamboo emptyList = [];
echoln(whatIs(numbers)); // Outputs: LIST

Mixed-Type Collections

TinyPanda lets you mix different kinds of data inside the same list. You don't have to stick to just numbers or just words. You can mix them all up together:

bamboo myList = [99, true, "hello", 3.14, fn(x){x * x}(9)];;

Strict Type Safety

Even though you can mix items, TinyPanda keeps track of exactly what type each item is. It never guesses or accidentally changes a type.

Important note

A integer like 99 is not the same thing as a string "99". Because TinyPanda checks both the value and the type, they will never match by accident!

bamboo list1 = [99, "10", true, "aprim"];
echoln(whatIs(list1[0])) // Outputs: INT
echoln(whatIs(list1[1])) // Outputs: STRING
echoln(contains(list1, 10)) // Outputs: false
echoln(contains(list1, "99")) // Outputs: false

Check out all available list builtins here.