Pascal and Syntactically Similar Languages
In Pascal, an enumerated type can be implicitly declared by listing the values in a parenthesised list:
var suit: (clubs, diamonds, hearts, spades);The declaration will often appear in a type synonym declaration, such that it can be used for multiple variables:
type cardsuit = (clubs, diamonds, hearts, spades); card = record suit: cardsuit; value: 1 .. 13; end; var hand: array of card; trump: cardsuit;The order in which the enumeration values are given matters. An enumerated type is an ordinal type, and the pred
and succ
functions will give the prior or next value of the enumeration, and ord
can convert enumeration values to their integer representation. Standard Pascal does not offer a conversion from arithmetic types to enumerations, however. Extended Pascal offers this functionality via an extended succ
function. Some other Pascal dialects allow it via type-casts. Some modern descendants of Pascal, such as Modula-3, provide a special conversion syntax using a method called VAL
; Modula-3 also treats BOOLEAN
and CHAR
as special pre-defined enumerated types and uses ORD
and VAL
for standard ASCII decoding and encoding.
Pascal style languages also allow for enumeration to be used as array index
var suitcount: array of integer;Read more about this topic: Enumerated Type
Famous quotes containing the words pascal, similar and/or languages:
“Had Cleopatras nose been shorter, the whole face of the world would have changed.”
—Blaise Pascal (16231662)
“We cannot feel strongly toward the totally unlike because it is unimaginable, unrealizable; nor yet toward the wholly like because it is staleidentity must always be dull company. The power of other natures over us lies in a stimulating difference which causes excitement and opens communication, in ideas similar to our own but not identical, in states of mind attainable but not actual.”
—Charles Horton Cooley (18641929)
“People in places many of us never heard of, whose names we cant pronounce or even spell, are speaking up for themselves. They speak in languages we once classified as exotic but whose mastery is now essential for our diplomats and businessmen. But what they say is very much the same the world over. They want a decent standard of living. They want human dignity and a voice in their own futures. They want their children to grow up strong and healthy and free.”
—Hubert H. Humphrey (19111978)