Content deleted Content added
"Character data type"? |
answer to Neilc about character type |
||
Line 23:
What does the "character data type" refer to? (Just some notion of a single byte type that allows 7-bit ASCII plus extensions to be represented, or something more complex?) I think it would be worth elaborting on what this feature is and why it wasn't convenient to use with B. [[User:Neilc|Neilc]] 10:32, 19 Jun 2005 (UTC)
(Not sure if this belongs on the page. Hard-core techies already know, and
most others don't care, but here's the answer: here "character data type"
just refers to a simple byte type, typically 8 or 9 bits in B implementations,
though at least one also supported 6 bit characters. The difficulty arises with addresses. When B words are interpreted as addresses, they are the addresses of words (variously 16, 18, or 36 bits on known implementations). Incrementing an address gives you the address of the following word. This is the same as the hardware addressing scheme on the PDP-7 and Honeywell machines, but different to almost anything modern, where addresses are of bytes. Addresses are very important in B (as in C), for instance they are the only way to do call-by-reference, to refer to dynamically allocated objects etc. So it can be a pain that you can't obtain the address of a byte, especially on a modern machine where the hardware does support that. BTW, the way characters were handled in B was via a pair of library functions
char(string, i)
which gave as result the i'th character of a string which started at the word address string, and
lchar(string, i, ch) which updated i'th character of string to have value ch.
)
|