PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Squirrel

Squirrel

Squirrel is a pl created in 2003 by Alberto Demichelis.

#194on PLDB 19Years Old 1.7kUsers
0Books 0Papers 2kRepos

Try now: Riju · TIO

Squirrel is a high level imperative, object-oriented programming language, designed to be a light-weight scripting language that fits in the size, memory bandwidth, and real-time requirements of applications like video games and hardware such as Electric Imp. MirthKit, a simple toolkit for making and distributing open source, cross-platform 2D games, uses Squirrel for its platform. It is used extensively by Code::Blocks for scripting and was also used in Final Fantasy Crystal Chronicles: My Life as a King. Read more on Wikipedia...


Example from Riju:
print("Hello, world!\n")
Example from hello-world:
print("Hello World");
Example from the Hello World Collection:
#!/usr/bin/squirrelsh // Hello world in Squirrel printl("Hello, world!");
Example from Linguist:
//example from http://www.squirrel-lang.org/#documentation local table = { a = "10" subtable = { array = [1,2,3] }, [10 + 123] = "expression index" } local array=[ 1, 2, 3, { a = 10, b = "string" } ]; foreach (i,val in array) { ::print("the type of val is"+typeof val); } ///////////////////////////////////////////// class Entity { constructor(etype,entityname) { name = entityname; type = etype; } x = 0; y = 0; z = 0; name = null; type = null; } function Entity::MoveTo(newx,newy,newz) { x = newx; y = newy; z = newz; } class Player extends Entity { constructor(entityname) { base.constructor("Player",entityname) } function DoDomething() { ::print("something"); } } local newplayer = Player("da playar"); newplayer.MoveTo(100,200,300);
Example from Wikipedia:
class BaseVector { constructor(...) { if(vargv.len() >= 3) { x = vargv[0]; y = vargv[1]; z = vargv[2]; } } x = 0; y = 0; z = 0; } class Vector3 extends BaseVector { function _add(other) { if(other instanceof ::Vector3) return ::Vector3(x+other.x,y+other.y,z+other.z); else throw "wrong parameter"; } function Print() { ::print(x+","+y+","+z+"\n"); } } local v0 = Vector3(1,2,3) local v1 = Vector3(11,12,13) local v2 = v0 + v1; v2.Print();

Language features

Feature Supported Example Token
Strings
"Hello world"
"
Print() Debugging print
Line Comments
// A comment
//
Comments
Semantic Indentation ϴ
xaml.html · squirrel.html · zig.html

View source

PLDB - Build the next great programming language · v2022 · Day 32 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub · feedback@pldb.com