Questions Columns Rows
GitHub icon

Classroom Object Oriented Language

Classroom Object Oriented Language - Programming language

< >

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

#371on PLDB 27Years Old 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 }; };

View source

- Build the next great programming language Search Add Language Features Creators Resources About Blog Acknowledgements Stats Sponsor Traffic Traffic Today Day 267 feedback@pldb.com Logout