|
|
1.1 ! root 1: .TH HOC 1 ! 2: .SH NAME ! 3: hoc \- interactive floating point language ! 4: .SH SYNOPSIS ! 5: .B hoc ! 6: [ file ... ] ! 7: .SH DESCRIPTION ! 8: .I Hoc ! 9: interprets a simple language for floating point arithmetic, ! 10: at about the level of BASIC, with C-like syntax and ! 11: functions and procedures with arguments and recursion. ! 12: .PP ! 13: The named ! 14: .IR file s ! 15: are read and interpreted in order. ! 16: If no ! 17: .I file ! 18: is given or if ! 19: .I file ! 20: is `\-' ! 21: .I hoc ! 22: interprets the standard input. ! 23: .PP ! 24: .I Hoc ! 25: input consists of ! 26: .I expressions ! 27: and ! 28: .IR statements . ! 29: Expressions are evaluated and their results printed. ! 30: Statements, typically assignments and function or procedure ! 31: definitions, produce no output unless they explicitly call ! 32: .IR print . ! 33: .PP ! 34: Variable names are the usual syntax, including `_'; the name `_' ! 35: by itself contains the value of the last expression evaluated. ! 36: The variables E, PI, PHI, GAMMA and DEG are predefined; ! 37: the last is 59.25..., degrees per radian. ! 38: .PP ! 39: Expressions are formed with these operators: ! 40: .nf ! 41: .ta .5i 1.5i ! 42: ^ exponentiation ! 43: ! \- ++ \-\- unary logical and arithmetic negation, ... ! 44: * / % the obvious ! 45: + \- ditto ! 46: > >= < <= == != ! 47: && ! 48: \(or\(or ! 49: = += \-= \(**= /= %= ! 50: .fi ! 51: Built in functions include ! 52: .IR abs , ! 53: .I atan ! 54: (one argument), ! 55: .IR cos , ! 56: .IR exp , ! 57: .IR int , ! 58: .IR log , ! 59: .IR log10 , ! 60: .IR sin , ! 61: and ! 62: .IR sqrt . ! 63: The function ! 64: .I read(x) ! 65: reads a value into the variable ! 66: .IR x ; ! 67: the statement ! 68: .I print ! 69: prints a list of expressions that may include ! 70: string constants such as ! 71: .IR \&\&\&"hello\en" . ! 72: .PP ! 73: Control flow includes ! 74: .IR if-else , ! 75: .IR while , ! 76: and ! 77: .IR for , ! 78: with braces for grouping. ! 79: End of line marks end of statement, as does a semicolon. ! 80: Comments begin with # and continue to end of line. ! 81: .PP ! 82: Functions and procedures are introduced by the words ! 83: .I func ! 84: and ! 85: .IR proc ; ! 86: .I return ! 87: is used to return, with a value from a function. ! 88: Within a function or procedure, ! 89: arguments are referred to as ! 90: .IR $1 , ! 91: .IR $2 , ! 92: etc.; all other variables are global. ! 93: .SH "SEE ALSO" ! 94: .I ! 95: The Unix Programming Environment ! 96: by Brian Kernighan and Rob Pike. ! 97: .br ! 98: .IR bas (1), ! 99: .IR bc (1) ! 100: and ! 101: .IR dc (1). ! 102: .SH BUGS ! 103: Error recovery is imperfect within function and procedure definitions. ! 104: .br ! 105: The treatment of newlines is not exactly user-friendly.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.