![](https://csdnimg.cn/release/download_crawler_static/4254537/bg5.jpg)
In contrast to the pervasive syntax variation that occurred during the creation of B, the
core semantic content of BCPLits type structure and expression evaluation rules-
remained intact. Both languages are typeless, or rather have a single data type, the
`word,' or `cell,' a fixed-length bit pattern. Memory in these languages consists of a
linear array of such cells, and the meaning of the contents of a cell depends on the
operation applied. The + operator, for example, simply adds its operands using the
machine's integer add instruction, and the other arithmetic operations are equally
unconscious of the actual meaning of their operands. Because memory is a linear
array, it is possible to interpret the value in a cell as an index in this array, and BCPL
supplies an operator for this purpose. In the original language it was spelled rv, and
later !, while B uses the unary *. Thus, if p is a cell containing the index of (or
address of, or pointer to) another cell, *p refers to the contents of the pointed-to cell,
either as a value in an expression or as the target of an assignment.
Because pointers in BCPL and B are merely integer indices in the memory array,
arithmetic on them is meaningful: if p is the address of a cell, then p+1 is the address
of the next cell. This convention is the basis for the semantics of arrays in both
languages. When in BCPL one writes
let V = vec 10
or in B,
auto V[10];
the effect is the same: a cell named V is allocated, then another group of 10 contiguous
cells is set aside, and the memory index of the first of these is placed into V. By a
general rule, in B the expression
*(V+i)
adds V and i, and refers to the i-th location after V. Both BCPL and B each add
special notation to sweeten such array accesses; in B an equivalent expression is
V[i]
and in BCPL
V!i
This approach to arrays was unusual even at the time; C would later assimilate it in an
even less conventional way.
None of BCPL, B, or C supports character data strongly in the language; each treats
strings much like vectors of integers and supplements general rules by a few
conventions. In both BCPL and B a string literal denotes the address of a static area
initialized with the characters of the string, packed into cells. In BCPL, the first
packed byte contains the number of characters in the string; in B, there is no count
and strings are terminated by a special character, which B spelled `*e'. This change
was made partially to avoid the limitation on the length of a string caused by holding
the count in an 8- or 9-bit slot, and partly because maintaining the count seemed, in
our experience, less convenient than using a terminator.
Individual characters in a BCPL string were usually manipulated by spreading the
string out into another array, one character per cell, and then repacking it later; B