Skip to content

Latest commit

 

History

History
50 lines (44 loc) · 2.48 KB

b202x.md

File metadata and controls

50 lines (44 loc) · 2.48 KB

B 202x is a new dialect of the B programming language. B was a predecessor to C designed to run on the PDP-7 and similar word-oriented machines, so it is preadapted to work well on the PDP-8/X. Indeed, the transition from B to C took place because B's word-oriented and typeless nature wasn't very well suited to the byte-oriented PDP-11.

Here are Brian Kernighan's B Tutorial, Ken Thompson's User's Reference to B for the PDP-11, and S.C. Johnson's User's Reference to B in MH-TSS. an operating system for the Honeywell (formerly GE) H6070, a 36-bit computer with an 18-bit address space. Note that the total length of these documents is less than 60 pages, and the two Reference manuals partly duplicate each other. For comparison, the ANSI C19 spec is 540 pages.

The following minor changes and additions separate B 2020 from the B described above (which was itself by no means unchanging); they are made to improve the familiarity of B to C programmers.

Incompatible changes:

  • \ instead of * as a character and string escape
  • the assignment operators are reversed (+= as in C, not =+ as in B)
    • Consequently => and =< have been removed
  • the && and || operators avoid the need for special treatment of & and |
  • separate variables from initial values with =
  • array declarations look like auto x[20], not auto x 20
  • spell extrn as extern
  • declare internal variables with static instead of no keyword
  • octal constants have octal digits only

Upward compatible additions:

  • //-style comments
  • 32-bit float constants (which will not work with integer operators)
  • Unicode character constants up to four bytes; Unicode string constants (UTF-8 internally)
  • identifiers of any length and Unicode
  • the 0x hexadecimal prefix on numbers
  • allow all declarations to be initialized
  • the break statement for loops and switch, which had not yet been invented
  • the continue statement, ditto
  • the do...while loop, ditto
  • the for loop, ditto; allow comma operators in the first and third expressions
  • the inline declaration keyword (maybe)
  • the register declaration keyword (puts things on page zero on the PDP-8/X)
  • all C type declaration keywords reserved for possible use by a linter