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

Classroom Object Oriented Language

Classroom Object Oriented Language

Classroom Object Oriented Language, aka Classroom Object Oriented Language, is a pl created in 1996 by Alexander Aiken.

#377on PLDB 26Years Old 345Users
0Books 0Papers 102Repos

Cool, an acronym for Classroom Object Oriented Language, is a computer programming language designed by Alexander Aiken for use in an undergraduate compiler course project. While small enough for a one term project, Cool still has many of the features of modern programming languages, including objects, automatic memory management, strong static typing and simple reflection. The reference Cool compiler is written in C++, built fully on the public domain tools. Read more on Wikipedia...


Example from hello-world:
class Main inherits IO { main(): Object { out_string("Hello World.\n") }; };
Example from Linguist:
(* This simple example of a list class is adapted from an example in the Cool distribution. *) class List { isNil() : Bool { true }; head() : Int { { abort(); 0; } }; tail() : List { { abort(); self; } }; cons(i : Int) : List { (new Cons).init(i, self) }; }; class Cons inherits List { car : Int; -- The element in this list cell cdr : List; -- The rest of the list isNil() : Bool { false }; head() : Int { car }; tail() : List { cdr }; init(i : Int, rest : List) : List { { car <- i; cdr <- rest; self; } }; };
Example from Wikipedia:
class Main inherits IO { main(): Object {{ out_string("Enter an integer greater-than or equal-to 0: "); let input: Int <- in_int() in if input < 0 then out_string("ERROR: Number must be greater-than or equal-to 0\n") else { out_string("The factorial of ").out_int(input); out_string(" is ").out_int(factorial(input)); out_string("\n"); } fi; }}; factorial(num: Int): Int { if num = 0 then 1 else num * factorial(num - 1) fi }; };

Language features

Feature Supported Example Token
Booleans true false
MultiLine Comments
(* A comment
*)
(* *)
Print() Debugging out_string
Comments
-- A comment
Line Comments
-- A comment
--
Semantic Indentation ϴ
capn-proto.html · cool.html · nsis.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