Classroom Object Oriented Language, aka Classroom Object Oriented Language, is an actively used programming language created in 1996.

23Years Old 1,020Users 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
  };
};
Edit

Last updated February 11th, 2019