Classroom Object Oriented Language, aka Classroom Object Oriented Language, is an actively used programming language created in 1996. 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...

23Years Old 20Users 0Jobs

Example code 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 code 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
  };
};

Trending Repos

repo stars description

Last updated November 14th, 2019