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:
“The conduct of God who disposes all things kindly, is to put religion into the mind by reason, and into the heart by grace. But to attempt to put it into the mind and heart by force and threats is not to put religion there, but terror.”
—Blaise Pascal (16231662)
“The history of all Magazines shows plainly that those which have attained celebrity were indebted for it to articles similar in natureto Berenicealthough, I grant you, far superior in style and execution. I say similar in nature. You ask me in what does this nature consist? In the ludicrous heightened into the grotesque: the fearful coloured into the horrible: the witty exaggerated into the burlesque: the singular wrought out into the strange and mystical.”
—Edgar Allan Poe (18091849)
“The less sophisticated of my forbears avoided foreigners at all costs, for the very good reason that, in their circles, speaking in tongues was commonly a prelude to snake handling. The more tolerant among us regarded foreign languages as a kind of speech impediment that could be overcome by willpower.”
—Barbara Ehrenreich (b. 1941)