Bs (programming language)
This article, Bs (programming language), has recently been created via the Articles for creation process. Please check to see if the reviewer has accidentally left this template after accepting the draft and take appropriate action as necessary.
Reviewer tools: Inform author |
This sandbox is in the article namespace. Either move this page into your userspace, or remove the {{User sandbox}} template.
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".[4]
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
# Distance (inches) light travels in a nanosecond.
186000 * 5280 * 12 / 1e9
11.78496
...
# Compound interest
# (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:
# initialize things:
var1 = 1
open("read", "infile", "r")
...
# compute:
while ?(str = read)
...
next
# clean up:
close("read")
...
# last statement executed (exit or stop):
exit
# last input line:
run
This example demonstrates I/O:
# Copy "oldfile" to "newfile".
open("read", "oldfile", "r")
open("write", "newfile", "w")
...
while ?(write = read)
...
# close "read" and "write":
close("read")
close("write")
# Pipe between commands.
open("ls", "!ls *", "r")
open("pr", "!pr -2 -h ’List’", "w")
while ?(pr = ls) ...
...
# 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
- ^ http://support.apple.com/kb/TA39862?viewlocale=en_US
- ^ The /FILES file, A/UX 3.0.1 installation media, Apple Inc. (1993)
- ^ a b The /usr/catman/u_man/man1/bs.1.Z file, A/UX 3.0.1 installation media, Apple Inc. (1993)
- ^ http://christtrekker.users.sourceforge.net/doc/aux/faq.html