HOME

TheInfoList



OR:

hoc, an acronym for High Order Calculator, is an interpreted
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
that was used in the 1984 book The Unix Programming Environment to demonstrate how to build interpreters using
Yacc Yacc (Yet Another Compiler-Compiler) is a computer program for the Unix operating system developed by Stephen C. Johnson. It is a Look Ahead Left-to-Right Rightmost Derivation (LALR) parser generator, generating a LALR parser (the part of a com ...
. hoc was developed by
Brian Kernighan Brian Wilson Kernighan (; born 1942) is a Canadian computer scientist. He worked at Bell Labs and contributed to the development of Unix alongside Unix creators Ken Thompson and Dennis Ritchie. Kernighan's name became widely known through co-au ...
and
Rob Pike Robert "Rob" Pike (born 1956) is a Canadian programmer and author. He is best known for his work on the Go programming language and at Bell Labs, where he was a member of the Unix team and was involved in the creation of the Plan 9 from Bell La ...
as a glorified interactive calculator. Its basic functionality is to evaluate floating-point numerical expressions, e.g., . Then, variables were added, conditionals, loops, user-defined functions, simple IO, and more, using a syntax resembling C. An improved hoc interpreter was included in Eighth Edition
Research Unix The term "Research Unix" refers to early versions of the Unix operating system for DEC PDP-7, PDP-11, VAX and Interdata 7/32 and 8/32 computers, developed in the Bell Labs Computing Sciences Research Center (CSRC). History The term ''Research ...
in 1985, but it has not been generally adopted by commercial
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
systems or by
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
distributions. Instead, the earlier calculator languages dc and bc have become widespread on those systems. hoc survived and continued to evolve as part of the Plan 9 operating system. Several improved versions of Hoc were released as
free software Free software or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any adapted versions. Free software is a matter of liberty, no ...
by Bell Labs and other individuals (see list below). hoc is used as the primary scripting language for the Neuron simulator.


Examples

The following is a simple example of an interactive calculator session in hoc; text represents hoc's output: 1+2*3 7 angle=PI/3 r=sin(angle) r 0.866025 r*2 1.73205 And a simple example of functions and flow control: func atan2() atan2(2,3) 0.982794 atan2(0,0) atan2 domain error 0.0


References

*


External links

*


hoc implementations and versions

* AT&T versions: *
The original code from the Unix Programming Environment book
including hoc. *
Source code of hoc
from Bell Labs, released as
free software Free software or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any adapted versions. Free software is a matter of liberty, no ...
. This is the Research Unix version, slightly improved over the one in the book. *
Plan9 version of hoc
released under the Lucent Public License. This version is slightly different from the Research Unix version, with the most notable difference being that numbered function arguments ($1, $2, etc., as in the Unix shell) were replaced by named arguments (as in C). See also Plan 9'
hoc manual
* Other versions: *
an extended version of hoc
by Nelson H. F. Beebe. *
an extended version of hoc
by Nadav Y. Har'El. *
an extended version of hoc
by Jack Dennon. *

by Michael Hines, John W. Moore, and Ted Carnevale. {{Plan 9 commands Software calculators Free mathematics software Numerical programming languages Unix programming tools Plan 9 commands