📑 Table of Contents

B語言是一种通用的程序设计语言,大約於1969年時,由美國貝爾實驗室電腦科學家肯·湯普森丹尼斯·利奇的支持下設計。

B语言
設計者肯·汤普森
實作者肯·汤普森丹尼斯·利奇
发行时间1969年,​56年前​(1969[1]
型態系統无类型(所有东西都是
文件扩展名.b
受影响于
BCPL, PL/I, TMG英语TMG (language)
影響語言
C语言

肯·湯普森最初想在UNIX上開發一個Fortran編譯器,但後來引進了BCPL的風格,形成一個新語言即B語言。後來,丹尼斯·利奇以B語言為基礎開發出C語言,自從C語言漸漸發展成為目前世界上最常用的程式語言之一之後,B語言幾乎已遭棄置。

例子

编辑

下面是肯·湯普森在《B用户参考》中提供的源代碼[2]

/* The following function will print a non-negative number, n, to
   the base b, where 2<=b<=10.  This routine uses the fact that
   in the ASCII character set, the digits 0 to 9 have sequential
   code values.  */

printn(n, b) {
    extrn putchar;
    auto a;
    /* Wikipedia note: auto declares a variable with automatic
       storage (lifetime is function scope), not "automatic typing"
       as in C++11. */

    if (a = n / b) /* assignment, not test for equality */
        printn(a, b); /* recursive */
    putchar(n % b + '0');
}
/* The following program will calculate the constant e-2 to about
   4000 decimal digits, and print it 50 characters to the line in
   groups of 5 characters.  The method is simple output conversion
   of the expansion
     1/2! + 1/3! + ... = .111....
   where the bases of the digits are 2, 3, 4, . . . */

main() {
    extrn putchar, n, v;
    auto i, c, col, a;

    i = col = 0;
    while(i<n)
        v[i++] = 1;
    while(col<2*n) {
        a = n+1 ;
        c = i = 0;
        while (i<n) {
            c =+ v[i] *10;
            v[i++]  = c%a;
            c =/ a--;
        }
        putchar(c+'0');
        if(!(++col%5))
            putchar(col%50?' ': '*n');
    }
    putchar('*n*n');
}
v[2000];
n 2000;

參見

编辑

引用

编辑
  1. ^ B - computer programming language. [2021-03-14]. (原始内容存档于2015-02-10). 
  2. ^ Thompson, Ken. Users' Reference to B (PDF). Bell Laboratories. 7 January 1972 [21 March 2014]. (原始内容 (PDF)存档于17 March 2015). 

外部連結

编辑

📚 Artikel Terkait di Wikipedia

Modula-3

声明为一个变量、类型、过程、常量(英语:Constant (computer programming))或例外指定一个被称为标识符的符号(英语:Symbol (programming))作为名字。一个声明应用于其上的程序区域,叫做这个声明的作用域。作用域是可以

CPE

cpe或CPE可能指: 細胞病變作用(cytopathic effect) DNA中的啟動子 计算机工程(computer engineering) 用户驻地设备 常相位元件(Constant phase element) 英語混語方言(英语:English-based creole languages)(English-based

结对编程

Robert. Pair Programming Illuminated. Addison-Wesley. 2003: 24. ISBN 0-201-74576-3. "With any software development process there is a constant struggle to

LISP

(computer programming))的等价者。在程序代码中可以修改(可变)文字的值。例如,如果一个函数返回一个引述形式,而调用这个函数的代码修改这个形式,这可以改变这个函数在后续调用时的行为: * (defun should-be-constant () '(one two

ML语言

x, f y) 函数可以产生函数作为返回值,比如: fun constantFn k = (fn anything => k) 函数可以同时接受和产生函数,比如复合函数(英语:Function composition (computer science)): fun compose (f, g) =

ALGOL 68

14或字符串指示"abc",模态VOID只有一个值,其指示是EMPTY。在其他语言中,指示有时叫做“文字(英语:Literal (computer programming))”(literal)或“常值”(constant)。 铸型(cast)构成自一个模态标示(indicant)和随后的通常为闭合子句的封闭子句。铸型可被用

Fortran

Fortran的设计是很多其他语言的基础。其中最周知的是在1964年推出的BASIC,它基于了FORTRAN II,具有一些语法(英语:Syntax (programming languages))清理,尤其是更好的逻辑结构,和其他在交互式环境中使工作更加容易的变更。 在1953年后期,约翰·巴科斯(John W

歐拉-馬斯刻若尼常數

Euler constant: γ. (页面存档备份,存于互联网档案馆)" Donald Knuth (1997) The Art of Computer Programming, Vol. 1, 3rd ed. Addison-Wesley. ISBN 978-0-201-89683-1 Krämer, Stefan