Annotation of lucent/sys/man/1/hoc, revision 1.1.1.1

1.1       root        1: .TH HOC 1
                      2: .SH NAME
                      3: hoc \- interactive floating point language
                      4: .SH SYNOPSIS
                      5: .B hoc
                      6: [
                      7: .I file ...
                      8: ]
                      9: .SH DESCRIPTION
                     10: .I Hoc
                     11: interprets a simple language for floating point arithmetic,
                     12: at about the level of BASIC, with C-like syntax and
                     13: functions.
                     14: .PP
                     15: The named
                     16: .I files
                     17: are read and interpreted in order.
                     18: If no
                     19: .I file
                     20: is given or if
                     21: .I file
                     22: is
                     23: .L -
                     24: .I hoc
                     25: interprets the standard input.
                     26: .PP
                     27: .I Hoc
                     28: input consists of
                     29: .I expressions
                     30: and
                     31: .IR statements .
                     32: Expressions are evaluated and their results printed.
                     33: Statements, typically assignments and function or procedure
                     34: definitions, produce no output unless they explicitly call
                     35: .IR print .
                     36: .PP
                     37: Variable names have the usual syntax, including 
                     38: .LR _ ;
                     39: the name 
                     40: .L _
                     41: by itself contains the value of the last expression evaluated.
                     42: The variables
                     43: .BR E ,
                     44: .BR PI ,
                     45: .BR PHI ,
                     46: .BR GAMMA
                     47: and
                     48: .B DEG 
                     49: are predefined; the last is 59.25..., degrees per radian.
                     50: .PP
                     51: Expressions are formed with these C-like operators, listed by
                     52: decreasing precedence.
                     53: .TP
                     54: .B ^
                     55: exponentiation
                     56: .TP
                     57: .B ! - ++ --
                     58: .TP
                     59: .B * / %
                     60: .TP
                     61: .B + -
                     62: .TP
                     63: .B > >= < <= == !=
                     64: .TP
                     65: .B &&
                     66: .TP
                     67: .B ||
                     68: .TP
                     69: .B = += -= *= /= %=
                     70: .PP
                     71: Built in functions are
                     72: .BR abs ,
                     73: .BR acos ,
                     74: .BR asin ,
                     75: .B atan
                     76: (one argument),
                     77: .BR cos ,
                     78: .BR cosh ,
                     79: .BR exp ,
                     80: .BR int ,
                     81: .BR log ,
                     82: .BR log10 ,
                     83: .BR sin ,
                     84: .BR sinh ,
                     85: .BR sqrt ,
                     86: .BR tan ,
                     87: and
                     88: .BR tanh .
                     89: The function
                     90: .B read(x)
                     91: reads a value into the variable
                     92: .B x
                     93: and returns 0 at EOF;
                     94: the statement
                     95: .B print
                     96: prints a list of expressions that may include
                     97: string constants such as
                     98: .BR \&\&\&"hello\en" .
                     99: .PP
                    100: Control flow statements are
                    101: .BR if - else ,
                    102: .BR while ,
                    103: and
                    104: .BR for ,
                    105: with braces for grouping.
                    106: Newline ends a statement.
                    107: Backslash-newline is equivalent to a space.
                    108: .PP
                    109: Functions and procedures are introduced by the words
                    110: .B func
                    111: and
                    112: .BR proc ;
                    113: .B return
                    114: is used to return with a value from a function.
                    115: Within a function or procedure,
                    116: arguments are referred to as
                    117: .BR $1 ,
                    118: .BR $2 ,
                    119: etc.; all other variables are global.
                    120: .SH EXAMPLES
                    121: .EX
                    122: func gcd() {
                    123:        temp = abs($1) % abs($2)
                    124:        if(temp == 0) return abs($2)
                    125:        return gcd($2, temp)
                    126: }
                    127: for(i=1; i<12; i++) print gcd(i,12)
                    128: .EE
                    129: .SH SOURCE
                    130: .B /sys/src/cmd/hoc
                    131: .SH "SEE ALSO"
                    132: .IR bc (1),
                    133: .IR dc (1)
                    134: .br
                    135: B. W. Kernighan and R. Pike,
                    136: .I
                    137: The Unix Programming Environment,
                    138: Prentice-Hall, 1984
                    139: .SH BUGS
                    140: Error recovery is imperfect within function and procedure definitions.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.