Next: , Up: Expressions   [Index]


6.1 Constants and Variables

INTERCAL-72 C-INTERCAL CLC-INTERCAL J-INTERCAL
yes all versions all versions all versions

The basic operands in INTERCAL are constants and variables. These together make up what in other languages are known as ‘lvalues’, that is, operands to which values can be assigned. (Constants can also be lvalues in INTERCAL, but by default C-INTERCAL turns this off because it carries an efficiency penalty and can be confusing; this can be turned on with the -v option (see -v).)

Constants can have any integer value from 0 to 65535 inclusive; higher values (up to 4294967295) can be generated in programs, but cannot be specified literally as constants. (The usual way to work around this limitation is to interleave two constants together; see Mingle.) A constant is written as a mesh (#) followed by a number in decimal. At the start of the program, all constants have the same value as the number that identifies them; for instance, #100 has 100 as its value, and it’s strongly advised not to change the value of a constant during the execution of a program.

There are four types of variable: 16-bit and 32-bit unsigned integers, and arrays of 16-bit and 32-bit unsigned integers. These are represented with a spot, twospot, tail, and hybrid (., :, ,, and ;) respectively. For this reason, integers within the range 0 to 65535 inclusive are known as ‘onespot numbers’, and integers within the range 0 to 4294967295 inclusive are known as ‘twospot numbers’; variables with those ranges are known as onespot and twospot variables. (Note that arrays did not work in C-INTERCAL before version 0.7.)

Variables are represented with a character representing their data type, followed by an integer from 1 to 65535 inclusive, written in decimal. Non-array variables don’t need to be declared before they are used; they automatically exist in any program that uses them. For instance, .1 and .001 are the same variable, onespot number 1. Array variables need to be dimensioned before they are used, by assigning dimensions to them; see Calculate.


Next: , Up: Expressions   [Index]