Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Types

SillyScript is built on a handful of core-types.

Booleans

The bool type can only store two options: true or false.

SillyScript JSON

SillyScript code:

true;
false;

The equivalent JSON:

[
	true,
	false
]

Numbers

There are two number types: int and float. floats can have numbers with decimal places, ints must be integers.

SillyScript JSON

SillyScript code:

1;
0.5;

The equivalent JSON:

[
	1,
	0.5
]

Strings

The string type is a string of characters. At the current moment you can only use double-quotes for strings.

SillyScript JSON

SillyScript code:

"Hello world";

The equivalent JSON:

[
	"Hello world"
]

Null

Types can be assigned null to store nothing. When passing null to a typed entry, the type must be “nullable”. A type can be made “nullable” by adding a question mark ? to the end of it.

Non-nullable types can be passed the nullable ones, but the opposite is not true.

SillyScript JSON

SillyScript code:

null;
 
def MaybeGiveInt(a: int?) -> list:
	a;
 
MaybeGiveInt(12);
MaybeGiveInt(null);

The equivalent JSON:

[
	null,
	[ 12 ],
	[ null ]
]

List

A list of data entries. A mixed list is denoted with just list.

A list that only contains a single type can be denoted using TYPE list (for example: int list).

SillyScript JSON

SillyScript code:

def OneTwoThree() -> int list:
	1; 2; 3;
 
def TakeList(list: int list) -> dict:
	data: list;
 
TakeList(OneTwoThree());

The equivalent JSON:

[
	{
		"data": [1, 2, 3]
	}
]

Dictionary

An unordered list of data entries with a unique identifier for each entry. A mixed dict is denoted with just dict.

A dictionary that only contains a single type can be denoted using TYPE dict. For example: string dict.

Roles

A “role” can be given to a type as a piece of metadata. This is done using an exclamation point !.

def Something(input: dict!funny) -> dict!sad:
	count: input.number

A type with a role can only be passed to another type with the same role identifier.

# Error: dict!sad cannot be passed to dict!funny.
Something(Something({ number: 32 }));