COMTERP(1)

๐Ÿ“ฆ
version 2.1.1+git.2025.07.26.a1 ยท 2 versions
, in ubuntu stonking

okay bestie ๐Ÿ’– welcome to the COMTERP(1) glow-up. This is the General Commands Manual page for comterp, and it's literally giving distributed command interpreter demonstrator energy. No cap. โœจ


๐ŸŒธ NAME ๐ŸŒธ

comterp โ€” distributed command interpreter demonstrator ๐Ÿซถ

๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

comterp
comterp remote
comterp server "portnum"
comterp logger "portnum"
comterp client "host" "portnum" ["file"]
comterp telcat "host" "portnum" ["file"]
comterp run "file"
comterp "expr"

๐Ÿ’– DESCRIPTION ๐Ÿ’–

comterp demonstrates the command interpreter incorporated into ivtools. A user (or client program) can interact with comterp via stdin and stdout or telnet (when ACE is built in). The command syntax is a semi-colon separated list of commands with arbitrary number of parameters enclosed in parenthesis, with support for optional parameters and keyword arguments, i.e:

       command2(arg1 arg2 arg3 :key1 val1 :key2 val2);
       command1(arg1 arg2 arg3 :key1 val1 :key2 val2)

C-like binary expressions can be embedded anywhere in the command language, using the operators in the table below. Variables can be created on the fly with an assignment operator (i.e "ball=1" creates a integer "ball" variable set to 1). Unterminated expressions cause an automatic command line extension (until the parser determines the expression is complete). "(), "{}", and "[]" can all be used interchangeably. periodt.


๐ŸŽ€ COMMAND OPTIONS ๐ŸŽ€

  • comterp โ€” Invoke a single command interpreter to interact with via stdin and stdout. iconic.
  • comterp remote โ€” Invoke a single command interpreter, like the default, and include a remote command for accessing other comterp's in server mode. ๐Ÿฆ‹
  • comterp server "portnum" โ€” Listens for and accept connections on portnum, then setup a command interpreter to wait for and process commands from that connection. ๐Ÿ”ฅ
  • comterp logger "portnum" โ€” Listens for and accept connections on portnum, then simply forward the incoming messages to stdout, while ack'ing back with newlines. For debugging purposes, not really a use of the interpreter. ๐Ÿ’€
  • comterp client "host" "portnum" ["file"] โ€” Connect to a portnum on a host and send/receive new-line terminated text buffers. For debugging purposes, not really a use of the interpreter. ๐Ÿซถ
  • comterp telcat "host" "portnum" ["file"] โ€” Connect to a portnum on a host, cat the file, then close the connection. Not really a use of the interpreter either. ๐Ÿ“
  • comterp run "file" โ€” Run contents of file then exit. โœจ
  • comterp "expr" โ€” Evaluate single expression then exit. ๐Ÿ’…

๐Ÿ”ฅ OPERATOR TABLE ๐Ÿ”ฅ

okay so here's the entire operator table, bestie, copied with love and zero edits. It's giving priority and order realness:

           Operators  Command Name   Priority    Order       Type
           ---------  ------------   --------    -----       ----
           .          dot            130         R-to-L      binary
           `          bquote         125         R-to-L      unary-prefix
           !          negate         110         R-to-L      unary-prefix
           ~          bit_not        110         R-to-L      unary-prefix
           ++         incr           110         R-to-L      unary-prefix
           ++         incr_after     110         R-to-L      unary-postfix
           -          minus          110         R-to-L      unary-prefix
           --         decr           110         R-to-L      unary-prefix
           --         decr_after     110         R-to-L      unary-postfix
           **         repeat         90          L-to-R      binary
           ..         iterate        80          L-to-R      binary
           %          mod            70          L-to-R      binary
           *          mpy            70          L-to-R      binary
           /          div            70          L-to-R      binary
           +          add            60          L-to-R      binary
           -          sub            60          L-to-R      binary
           <<         lshift         55          L-to-R      binary
           >>         rshift         55          L-to-R      binary
           <          lt             50          L-to-R      binary
           <=         lt_or_eq       50          L-to-R      binary
           >          gt             50          L-to-R      binary
           >=         gt_or_eq       50          L-to-R      binary
           !=         not_eq         45          L-to-R      binary
           ==         eq             45          L-to-R      binary
           &          bit_and        44          L-to-R      binary
           ^          bit_xor        43          L-to-R      binary
           |          bit_or         42          L-to-R      binary
           &&         and            41          L-to-R      binary
           ||         or             40          L-to-R      binary
           ,          tuple          35          L-to-R      binary
           ,,         stream concat  33          L-to-R      binary
           $          stream         32          R-to-L      unary-prefix
           $$         list           32          R-to-L      unary-prefix
           %=         mod_assign     30          R-to-L      binary
           *=         mpy_assign     30          R-to-L      binary
           +=         add_assign     30          R-to-L      binary
           -=         sub_assign     30          R-to-L      binary
           /=         div_assign     30          R-to-L      binary
           =          assign         30          R-to-L      binary
           ;          seq            10          L-to-R      binary

โœจ MATHEMATICAL COMMANDS: โœจ

  • n=min(a b) โ€” return minimum of a and b ๐ŸŒธ
  • n=max(a b) โ€” return maximum of a and b ๐ŸŒธ
  • n=abs(a) โ€” return absolute value of a ๐ŸŒธ
  • dbl=exp(x) โ€” returns the value e raised to the power of x ๐ŸŒธ
  • dbl=log(x) โ€” returns the natural logarithm of x ๐ŸŒธ
  • dbl=log10(x) โ€” returns the base-10 logarithm of x ๐ŸŒธ
  • dbl=log2(x) โ€” returns the base-2 logarithm of x ๐ŸŒธ
  • dbl=pow(x y) โ€” returns the value of x raised to the power of y ๐ŸŒธ
  • dbl=acos(x) โ€” returns the arc cosine of x in radians ๐ŸŒธ
  • dbl=asin(x) โ€” returns the arc sine of x in radians ๐ŸŒธ
  • dbl=atan(x) โ€” returns the arc tangent of x in radians ๐ŸŒธ
  • dbl=atan2(y x) โ€” returns the arc tangent of y over x ๐ŸŒธ
  • dbl=cos(x) โ€” returns the cosine of x radians ๐ŸŒธ
  • dbl=sin(x) โ€” returns the sine of x radians ๐ŸŒธ
  • dbl=tan(x) โ€” returns the tangent of x radians ๐ŸŒธ
  • dbl=sqrt(x) โ€” returns square root of x ๐ŸŒธ
  • dbl=pi() โ€” returns the value of pi ๐ŸŒธ
  • dbl=radtodeg(dbl) โ€” convert radians to degrees ๐ŸŒธ
  • dbl=degtorad(dbl) โ€” convert degrees to radians ๐ŸŒธ
  • num=floor(num) โ€” return closest integer value less than or equal to argument ๐ŸŒธ
  • num=ceil(num) โ€” return closest integer value greater than or equal to argument ๐ŸŒธ
  • num=round(num) โ€” return closest integer value ๐ŸŒธ

๐Ÿ’ซ AFFINE TRANSFORM AND MATRIX COMMANDS: ๐Ÿ’ซ

  • point=xform(x,y a00,a01,a10,a11,a20,a21) โ€” affine transform of x,y coordinates ๐Ÿฆ‹
  • affine=invert(a00,a01,a10,a11,a20,a21) โ€” invert affine transform ๐Ÿฆ‹
  • matrix=xpose(matrix) โ€” transpose an arbitrary matrix ๐Ÿฆ‹
  • matrix=matrix*matrix โ€” matrix multiplication ๐Ÿฆ‹

๐ŸŽฒ STATISTICAL/RANDOM COMMANDS: ๐ŸŽฒ

  • sum(val1[,val2[,...,valn]]) โ€” return sum of values ๐Ÿ“
  • mean(val1[,val2[,...,valn]]) โ€” return mean of values ๐Ÿ“
  • var(val1[,val2[,...,valn]]) โ€” return variance of values ๐Ÿ“
  • stddev(val1[,val2[,...,valn]]) โ€” return standard deviation of values ๐Ÿ“
  • rand([minval,maxval]) โ€” return random number between 0 and 1 or minval,maxval ๐Ÿ“
  • srand(seedval) โ€” seed random number generator ๐Ÿ“

๐Ÿ“‹ LIST COMMANDS: ๐Ÿ“‹

  • lst=list([lst|strm|val|fileobj|pipeobj) :strmlst :attr :size n) โ€” create list, copy list, or convert stream ๐Ÿงš
  • val=at(lst|attrlst|str n :set val :ins val) โ€” return (or set or insert after) nth item in a list or string ๐Ÿงš
  • num=size(lst|attrlst|str) โ€” return size of a list (or string) ๐Ÿงš
  • val=index(lst|str val|char|str :last :all :substr) โ€” return index of value (or char or string) in list (or string), nil if not found. ๐Ÿงš

๐ŸŒŠ STREAM COMMANDS: ๐ŸŒŠ

  • strm=stream(strm|lst|attrlst|val|fileobj|pipeobj) โ€” copy stream or convert list (unary $) ๐Ÿ’ง
  • val=next(stream :skim) โ€” return next value from stream, don't recurse if :skim ๐Ÿ’ง
  • cnt=each(strm) โ€” traverse stream returning its length ๐Ÿ’ง
  • comp=filter(comps classid) โ€” filter stream of comps for matching classid ๐Ÿ’ง

๐ŸŽฎ CONTROL COMMANDS (using post evaluation): ๐ŸŽฎ

  • val=cond(testexpr trueexpr falseexpr) โ€” evaluate testexpr, and if true, evaluate and return trueexpr, otherwise evaluate and return falseexpr ๐Ÿ•น๏ธ
  • val=if(testexpr :then expr :else expr) โ€” evaluate testexpr and execute the :then expression if true, the :else expression if false. ๐Ÿ•น๏ธ
  • val=for(initexpr whileexpr [nextexpr [bodyexpr]] :body expr) โ€” for loop ๐Ÿ•น๏ธ
  • val=while([testexpr [bodyexpr]] :nilchk :until :body expr ) โ€” while loop ๐Ÿ•น๏ธ
  • val=switch(val key-body-pairs) โ€” switch statement (:casen for pos., :case_n for neg., otherwise :symbol) ๐Ÿ•น๏ธ
  • continue โ€” skip to next iteration of for or while loop ๐Ÿ•น๏ธ
  • break([retval]) โ€” break out of for or while loop ๐Ÿ•น๏ธ

๐Ÿ”ฃ SYMBOL COMMANDS ๐Ÿ”ฃ

  • val=global(sym)|global(sym)=val|global(sym :clear)|global(:cnt) โ€” make symbol global ๐Ÿ’œ
  • int|lst=symid([sym [sym ...]] :max :cnt) โ€” return integer id(s) associated with symbol(s) ๐Ÿ’œ
  • sym|lst=symbol(symid [symid ...]) โ€” return symbol(s) associated with integer id(s) ๐Ÿ’œ
  • val|lst=symval(symv [symv ...]) โ€” return value(s) associated with symbol variables(s) ๐Ÿ’œ
  • symv|lst=symadd(sym|str [sym|str ...]) โ€” create symbol(s) and return without lookup. ๐Ÿ’œ
  • sym=symvar(symv) โ€” return symbol of symbol variable without lookup, for use on left hand side of assignment ๐Ÿ’œ
  • str=symstr(symv) โ€” return string version of symbol in symbol variable ๐Ÿ’œ
  • sym=bquote(sym) โ€” LISP-like backquote operator, returns symbol without lookup ๐Ÿ’œ
  • n=strref(str|symid) โ€” return string reference count ๐Ÿ’œ
  • bool=eq(sym1 sym2 :sym) โ€” symbol comparison ๐Ÿ’œ

๐Ÿ“ FILE COMMANDS ๐Ÿ“

  • fileobj|pipeobj=open([filename [modestr]] :pipe :in :out :err) โ€” open file command ๐Ÿ—‚๏ธ
  • close(fileobj|pipeobj|sockobj) โ€” close file command ๐Ÿ—‚๏ธ
  • [str]=print([fmtstr] [val [val1 [... valn]]] :string|:str :out :err :file fileobj|pipeobj :prefix str :flush) โ€” print value with optional format string ๐Ÿ—‚๏ธ
  • str=gets(fileobj|pipeobj|sockobj) โ€” gets a new-line terminated string from a file ๐Ÿ—‚๏ธ

๐Ÿงต STRING COMMANDS ๐Ÿงต

  • lst=split(sym|str :tokstr [delim] :tokval [delim] :keep :reverse) โ€” split symbol or string into list of characters (or tokens). ๐Ÿชก
  • str=join(lst :sym) โ€” join list of characters into string ๐Ÿชก
  • str=substr(str n|str :after :nonil) โ€” extract characters from a string (:nonil returns string if no match) ๐Ÿชก
  • bool=eq(str1 str2 :n len) โ€” partial string comparison ๐Ÿชก

๐Ÿ”— ATTRIBUTE COMMANDS ๐Ÿ”—

  • sym=attrname(attribute) โ€” return name field of dotted pair ๐ŸŽ€
  • val=attrval(attribute) โ€” return value field of dotted pair ๐ŸŽ€
  • dotlst=dot(name) โ€” construct empty dotted pair list ๐ŸŽ€

โ„น๏ธ INFO COMMANDS โ„น๏ธ

  • help(cmdname [cmdname ...] :all :posteval) โ€” help for commands ๐Ÿ’ก
  • optable(:bypri :byopr :bycom) โ€” print contents of operator table ๐Ÿ’ก

๐Ÿ› DEBUG COMMANDS ๐Ÿ›

ok so when your script is acting up and you need to peek under the hood, this is the whole toolbox. bestie, these are the little flashlights you point at your own code. ๐Ÿ”ฆ

  • val=trace([flag] :get) โ€” turns trace mode on or off, or straight-up sets it. pass the flag to set, or use the :get key to just ask what the vibe currently is and get it back as val.
  • pause([msgstr]) โ€” freezes script execution right there and waits for you to hit C/R. yes, it literally just pauses and stares at you. you can hand it a msgstr to say something while it waits. ๐Ÿซถ
  • step() โ€” toggles stepwise script execution. one step at a time, no rushing, we're being careful now.
  • mute([flag]) โ€” sets the mute flag, or toggles it if you don't pass anything. shhh. ๐Ÿคซ
  • postfix(arg1 [arg2 [arg3 ... [argn]]]) โ€” echoes your postfix arguments back at you unevaluated, which is the whole point. the decoration legend is iconic tbh: [narg|nkey] shows up after defined commands, {narg|nkey} after undefined commands, (narg) after keys, and a * trails any post-evaluation command. iykyk ๐Ÿ’…
  • parse(fileobj) โ€” parses a single expression out of a file. one expression. that's the assignment.

๐ŸŽฎ CONTROL COMMANDS ๐ŸŽฎ

these are the ones running the whole show. steering, exiting, spawning, remoting. main character energy, honestly. ๐Ÿ‘‘

  • arr=posteval(arg1 [arg2 [arg3 ... [argn]]]) โ€” post-evaluates every fixed argument (until it hits nil) and hands you back an array of the results.
  • quit() โ€” quits the interpreter. bye bestie ๐Ÿ‘‹
  • exit() โ€” exits the entire application. not just the interpreter, the whole thing. this is the "closing the laptop" of commands. ๐Ÿ’€
  • empty() โ€” the empty statement. it does nothing and it's thriving.
  • val=run(filename :str :popen) โ€” runs commands from a file, or from a string if you use :str. :popen is in there too.
  • sockobj=%s(hoststr portnum ) โ€” creates and opens a socket object. yes the object is literally called %s. yes that's the vibe. ๐ŸŒ
  • val=remote(hoststr|sockobj [portnum] cmdstr :nowait :str) โ€” remotely evaluates a command string, then locally evaluates the string that comes back. :nowait if you're not about waiting around, :str for string mode. ๐Ÿฆ‹
  • val=eval(cmdstr|funcobj [cmdstr|funcobj ...] :symret) โ€” evaluates a string (or a funcobj) as commands. throw :symret in there and it hands you a symbol back instead of nil.
  • funcobj=func(body :echo) โ€” wraps a whole body of commands up into an executable object. :echo included. little command burrito, so cute. ๐ŸŒฏ
  • val=shell(cmdstr) โ€” evaluates your command over in the shell.
  • usleep(msec) โ€” sleeps microseconds. yes, *micro*seconds, the man page said what it said. ๐Ÿ˜ด

๐Ÿงฐ UTILITY COMMANDS ๐Ÿงฐ

the little odds and ends drawer. converters, type checkers, bitwise stuff, date stuff. everything you didn't know you needed. โœจ

  • nil([...]) โ€” accepts literally any arguments you throw at it and returns nil. unbothered. unshakeable. ๐Ÿ’œ
  • true([...]) โ€” accepts any arguments and returns true. yes queen, affirm it. โญ
  • false([...]) โ€” accepts any arguments and returns false. the hater of the trio.
  • c=char(num :u) โ€” converts any numeric into a char. :u for unsigned, bestie.
  • s=short(num :u) โ€” converts any numeric into a short. also has :u.
  • i=int(num :u) โ€” converts any numeric into an int. :u, you know the drill.
  • l=long(num :u) โ€” converts any numeric into a long. :u again, slay.
  • f=float(num) โ€” converts any numeric into a float. no :u here, sorry.
  • d=double(num) โ€” converts any numeric into a double. also no :u.
  • sym|lst=type(val [val ...]) โ€” returns the type symbol (or a list of them, if you passed several values) for your value(s). the "who even are you" command. ๐Ÿ•ต๏ธ
  • sym|lst=class(val [val ...]) โ€” returns the class symbol(s) for value(s) of object type. yes, type and class are two different things, girlies, don't get it twisted.
  • int=ctoi(char) โ€” converts a character into an integer.
  • flag=isspace(char) โ€” returns true if the character is whitespace.
  • flag=isdigit(char) โ€” returns true if the character is a numeric digit.
  • flag=isspace(char) โ€” returns true if the character is alphabetical. okay bestie, no cap, the page literally says isspace here and then describes it as alphabetical โ€” i'm just telling you what the man page says, i do not make the rules ๐Ÿ˜ญ๐Ÿ™ˆ
  • str=arg(n) โ€” returns the command line argument at n.
  • n=narg(n) โ€” returns the number of command line arguments.
  • num=nand(a b) โ€” bitwise NAND (negated AND). ๐Ÿ”ฅ
  • num=nor(a b) โ€” bitwise NOR (negated OR).
  • num=xnor(a b) โ€” bitwise XNOR (negated XOR).
  • dateobj|int = date([num|str|dateobj] :day :month :year :daymo :weekday) โ€” builds a date from days since 1/1/1901, or from a string. you can also pass in a num, str, or a whole dateobj, and there are keys for :day, :month, :year, :daymo and :weekday. it gives you back a dateobj or an int. calendar girl vibes. ๐ŸŽ€

๐ŸŒˆ ONLY IN SERVER MODE ๐ŸŒˆ

this one's exclusive, bestie. if you're not in server mode, you don't get an invite to this party.

  • str=timeexpr(comstr :sec n) โ€” turns your command string into something that executes at intervals, with :sec n setting the seconds between runs.

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

  • comdraw โ€” go say hi to its sibling.
fr fr, go read that one too, they're a matched set. ๐Ÿซถ

๐ŸŒ WEB PAGES ๐ŸŒ

the whole world wide web page for this lives at:

http://www.ivtools.org/ivtools/comterp.html

aaaaand that's the whole page, you made it to the end bestie, i'm so proud of you. ๐Ÿ’– this was the COMTERP(1) manual page โ€” that's the source and the version stamp right there โ€” and yes it comes with a date on it like every good manpage does, so go check the original footer if you need the exact day, because your girl is not about to make one up. now go forth and eval something iconic. periodt. ๐Ÿ’…โœจ๐Ÿฆ‹๐ŸŽ€

๐Ÿ“ฆ where this page comes from