请输入您要查询的百科知识:

 

词条 Bs (programming language)
释义

  1. History

  2. Design and Features

  3. Syntax Examples

  4. References

{{Orphan|date=September 2015}}

bs was a programming language from Apple Inc. that shipped with A/UX. It was described by Apple as "a compiler/interpreter for modest-sized programs".[1][2] It provides an interactive prompt or accepts a file containing commands.

History

The original man page is dated January 1992 and describes bs as "a language that is a remote descendant of BASIC, SNOBOL4, and C".[3] The "Semi-Official FAQ List for A/UX" page corroborates this claim by describing bs as a "kinda-BASIC interpreter".[2]

Design and Features

"The language is designed for programming tasks where

program development time is as important as the resulting

speed of execution. The language minimizes the formalities

of data declaration and file manipulation. Line-at-a-time

debugging, the trace and dump keywords, and useful run-time

error messages simplify program testing. Furthermore, you

can debug incomplete programs, test inner functions before

outer functions have been written, and test outer functions

before inner functions have been written."[3]

Syntax Examples

The following examples are derived from the original man page.

This example uses bs as a calculator:

$ bs

  1. Distance (inches) light travels in a nanosecond.

186000 * 5280 * 12 / 1e9

11.78496

...

  1. Compound interest
  2. (6% for 5 years on $1,000).

int = .06 / 4

bal = 1000

for i = 1 5*4 bal = bal + bal*int

bal - 1000

346.855007

...

exit

This example is the outline of a typical bs program:

  1. initialize things:

var1 = 1

open("read", "infile", "r")

...

  1. compute:

while ?(str = read)

...

next

  1. clean up:

close("read")

...

  1. last statement executed (exit or stop):

exit

  1. last input line:

run

This example demonstrates I/O:

  1. Copy "oldfile" to "newfile".

open("read", "oldfile", "r")

open("write", "newfile", "w")

...

while ?(write = read)

...

  1. close "read" and "write":

close("read")

close("write")

  1. Pipe between commands.

open("ls", "!ls *", "r")

open("pr", "!pr -2 -h ’List’", "w")

while ?(pr = ls) ...

...

  1. be sure to close (wait for) these:

close("ls")

close("pr")

This command line shows a way of running bs:

bs program 1 2 3

The example compiles and executes the file named program as

well as any statements typed from standard input. The

arguments 1, 2, and 3 are passed as arguments to the program

when it executes.

References

[3][4]

2 : Programming languages|Apple Inc. software

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/22 13:29:02