Pop-11 procedures take their parameters, if any from the top of the stack, and leave their results, if any, on the stack. Thus the procedure SIN removes the top item from the stack, computes its sine, and place this number on the stack. When we write:
sin(45) => ** 0.707107Then three things happen:
(1) 45 is put on the stack (2) SIN is called (invoked, applied, run...). SIN removes the top item (in this case, 45), computes its sine (in this case 0.7071), and puts this on the stack (3) The print arrow, '=>' prints and empties the stack.Had we wished to be obscure, we could have written, with exactly the same effect:
45; sin(); =>If there is nothing on the stack for a procedure like SIN then it complains and we get a MISHAP message.
Whatever is currently on the top of the stack is used by the procedure SIN. If this expression were executed with the stack empty, a MISHAP message would be printed indicating that the stack had underflowed, thus:
sin() => ;;; MISHAP - STE: STACK EMPTY (missing argument? missing result?) ;;; DOING : sin compile compileProvided the number of parameters (arguments) put on the stack when a procedure is called is the same number as taken by the procedure, any numbers previously on the stack are unaffected by the transaction.
Note the difference between writing
sin;which loads the sin procedure itself onto the stack and
sin();which actually causes the sin procedure to be executed. It may be useful to think of "()" as the "doit" brackets. If there's anything between the brackets, that says "doit to...", e.g. sin(45).