[SparForte][Banner]
[Top Main Menu] Intro | Tutorials | Reference | Packages | Examples | Contributors   [Back Page]      [Next Page]  

Enumerated Types

AdaScript also has an enumerated type. An enumerated type is a type with a list of literal names. Variables of the type can only be assigned one of the names in the list.

Enumerated types are naturally incompatible with one another, or any other type. They are not integers or strings and cannot be type cast into integers, strings or other enumerateds..

Ada: AdaScript doesn't (yet) have overloading so the items in the enumerated list cannot be overloaded with items from other enumerated types. That is, the names must be unique.

=> type fruit is (apple, blueberry, cherry);
=> f : fruit
=> f := apple
=> f := 5
f := 5;
      ^ type fruit (an enumerated type) is inherently different from a universal_numeric

Enumerated types are ordered and can be compared.

=> ? apple < blueberry
true
> ? apple = cherry
false
? blueberry in apple..cherry
true
=> f2 := apple
=> (Assuming f2 is a new fruit variable)
=> ? f2 = apple
true
=> ? f2
apple

There are two built-in enumerated types:

  • The boolean type is a predefined enumerated type with values "false" and "true".
  • The file_mode type has the values "in_file", "out_file" and "append_file".

There are more enumerated types in the built-in packages.


 
[Right Submenu]

 AdaScript versus GCC

 Case Sensitivity

 Reserved Words

 Comments

 Literals

 Bourne Shell Word Expansions

 Fundamental Types

 User-defined Types

 Enumerated Types

 Arrays

 Records

 Basic Assignment

 The @ and % Operands

 Command Argument Shortcuts

 Redirection and Pipelines

 Command Line Interaction

 Built-in Shell Commands

 The Current Directory

 Database Commands

 Flow of Control

 Other Statements/ Subprograms

 External Commands

 Block Statements and Subprograms

 TCP/IP Sockets

 Numeric Formatting with Put

 Interpreter Directives

 Command Line Options

 Command Reference

 ASCII and Latin_1 Character Sets

 Common Error Messages

 Common PHP Functions and the SparForte Equivalent

[Back to Top] Back To Top [Small Forte Symbol]