请输入您要查询的百科知识:

 

词条 Cool (programming language)
释义

  1. Features

  2. Examples

  3. References

  4. External links

{{nofootnotes|date=February 2010}}{{For|the COOL language in CLIPS|CLIPS}}{{Infobox programming language
|name = COOL
|paradigm = Object-oriented
|year = 1996
|designer = Alexander Aiken
|developer = Alexander Aiken
|latest release version =
|latest release date =
|typing = Static, strong, manifest
|implementations =
|dialects = Cool 2004, Cool 2005, Cool 2006, Cool 2007, Cool 2008, unCool
|influenced_by = Java, ML, Pascal, Sather
}}

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. It generates code for a MIPS simulator, SPIM. Thus, the language should port easily to other platforms. It has been used for teaching compilers at many institutions (such as the University of California at Berkeley, where it was first used or Shahid Beheshti University of Iran) and the software is stable.

This language is unrelated to the COOL language included in CLIPS.

Features

As the primary purpose of Cool is instruction, it lacks many of the features common to other, more general programming languages. For instance, the language supports less than comparisons but not greater than. The syntax is very much stripped down, and the "standard library" contains only a few basic classes. Separate compilation is not supported, though the compiler does support multiple source files as input. Every Cool program must define a class Main which must have a no-args main method in which execution flow begins. Namespaces are not supported.

Examples

"Hello, world!":

class Main inherits IO {  main() : Object {    out_string("Hello, world!\")  };};

A simple program for computing factorials:

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\")      else {        out_string("The factorial of ").out_int(input);        out_string(" is ").out_int(factorial(input));        out_string("\");      }      fi;  }};  factorial(num: Int): Int {    if num = 0 then 1 else num * factorial(num - 1) fi  };};

References

  • Cool: A Portable Project for Teaching Compiler Construction
  • PostScript
  • CoolAid: The Cool 2016 Reference Manual
  • [https://web.archive.org/web/20071226010926/http://users.cs.dal.ca/~jost/4131/uncool-manual.html (Un)CoolAid: The UnCool Reference Manual]

External links

  • Cool: The Classroom Object-Oriented Language project main page
  • [https://lagunita.stanford.edu/courses/Engineering/Compilers/Fall2014/about Stanford Compilers course page (MOOC)]
  • CoolToJS: An online, interactive Cool compiler

1 : Object-oriented programming languages

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/25 4:39:13