TEACH GLOSSARY PAGE 1 GLOSSARY ________ Programmers' Jargon Exposed =========================== NOTE: this file was originally produced by Mark Steedman, Steve Isard and Aaron Sloman (with some help from other colleagues) for students at the University of Sussex at some time in the 1970s. It has recently been updated and installed as a TEACH file. Last revised: 27 Nov 2000 POP11 words appear in upper case, and English words in lower case. Underlining of words, (of either variety) indicates that they are defined elsewhere in this glossary. Further information is available in the POP11 primer (TEACH PRIMER) and a summary of the most useful subset of POP11 can be found in TEACH POPCORE. To use the glossary as a sketchy introduction to POP11 terminology, begin with the entries for procedure, argument, variable, local pointer, and then carry on as you see fit. Address see location Apply call. See argument, procedure. Argument If you want to do something with particular POP11 objects for example square a number, add an item to a list, you give the objects "as arguments" to the appropriate procedure. The command SQ(2) applies the procedure SQ to the argument 2. CONS(2,[]) applies the procedure CONS to two arguments. See parameter. Assignment Changing the contents of a storage location, such as the value of a variable. For example 4 -> X; "A" -> HD(L); HD(L1) -> HD(L2); are assignments. See stack. Call To make a procedure do its thing you have to "call" it. If you define a procedure it cannot do anything until it has been compiled, i.e. translated into an internal format containing instructions in the machine language, or instructions that can be obeyed by an interpreter program. After it has been compiled, the commands in the procedure definition are not carried out until the procedure is called. See argument. "apply", and "invoke" are often used instead of "call". TEACH GLOSSARY PAGE 2 Communication A vague word used to acknowledge the fact that what one procedure does can affect what another one does. You may, for instance, hear it said that "procedures communicate by way of the stack." This means that a procedure can put an item on the stack for another to take off, as in HD(TL(X)); where TL leaves its result on the stack to serve as argument for HD. Sometimes procedures communicate via the values of global variables (bad style usually), or via some specific global database (e.g. the Pop-11 database), or via files on a hard disc. Nowdays procedures running on different machines can communicate by email! Compile A compiler is a program which takes in instructions written in a "high level language" (one that is easy for humans to understand, for example POP11) and translates them into instructions in a "low level "language", which a machine can run. Most compilers also do a lot of error-checking and print out messages to help the programmer identify mistakes, even before the program runs. See also incremental compiler and interpreter. Control When you run a program a sequence of instructions gets carried out. People sometimes talk of "control passing" from one instruction to the next, or from one procedure to another. If procedure F calls procedure G, then control is first in F then in G then, after G has finished, control is back in F again. Data structure A general word for complex computational objects, like lists, that have a number of different parts. In POP11 you can assume that everything is a data structure, except numbers (reals and integers). Declare You create, and name, new procedures, variables, operations, etc by "declaring" them with appropriate incantations (see DEFINE, VARS, OPERATION.) You can also declare an existing variable to be local to a new procedure. Usually a declaration does at least two things: it introduces a new identifier and it causes a location to be reserved for the value of that identifier. DEFINE A POP11 word which appears in one of the incantations with which you can define your own procedures. For example define fred (x); pr(x); pr(x); enddefine; TEACH GLOSSARY PAGE 3 creates a procedure which, if you call it, will print the value of its argument twice. For example fred(3); will print 33 fred([a b c]); will print [a b c][a b c] The definition also declares FRED and X to be variables. FRED is assigned the procedure as its value, and X is made a formal parameter of the procedure. If variables are declared inside a procedure definition then they will be local to the procedure. DEFINE can also be used to declare an operation. See VARS. Error The POP11 compiler looks for errors in the syntax of your program as it is read in and prints out error messages to help you decide what to correct. When the program executed the POP11 system looks for semantic errors, for example attempts to add a word to a number, for example VARS X; "CAT" -> X; X + 5 -> Z; A "run-time" error message will be printed out. Everybody gets lots of error messages. Execute see Call Formal variable see parameter Function Another word for procedure often used for procedures that take arguments and produce results. The word "function" is often used as a synonym for "procedure", e.g. in books on LISP. Global see Local, DEFINE, Procedure. Head see List, HD HD POP11 standard procedure which looks up HeaD of a list and leaves it on the stack. TEACH GLOSSARY PAGE 4 Identifier A sequence of one or more characters used as the name of a variable or label, for example X X3 X33YZ5 DRAW + ++ +*+. Not every sequence of characters is permitted as an identifier. There are three types of characters that can be used in identifiers. alphabetic A B C D ...... Z numeric 0 1 2 3 ...... 9 "sign" characters + * / = & $ : ! @ , etc. Permitted identifiers are of two types: alphanumeric: an alphabetic character possibly followed by a sequence of letters and numerals. sign: a sequence of one or more sign characters, for example ++// == /=/ etc. Some characters may not be used in identifiers, namely ; , ) ( [ ] Certain identifiers are standard POP11 words, for example DEFINE IF LENGTH HD + - <> Incremental compiler "Compile" is defined above. An incremental compiler is part of a running program. It does the same job as a compiler except that instead of compiling a complete program all at once, and then leaving that program to be run on its own, the incremental compiler allows new bits of program to be compiled, or old bits to be re-compiled, without re-starting the whole program. This can enormously speed up development and testing of programs, and in some cases can enable a running program to be modified or extended without disruption of the application. Using an incremental compiler has some of the advantages of a compiler and some of the advantages of an interpreter. For more on this see the Preface to the POP11 primer. (TEACH PRIMER). Infix See operation. Interpreter Instead of a compiler an interpreter is sometimes used. In this case the instructions in the programming language are not translated into machine code, but instead into some internal abstract language. Then the instructions in that language are obeyed by a previously compiled program called an "interpreter" which examines the user program step by step and takes appropriate action. A language (e.g. LISP) may have both a compiler and an interpreter. Execution of a program by an interpreter is usually slower than execution of the compiled language would be. However, the interpreted program may be more compact and more flexible, e.g. easier to modify at "run time" and easier to debug. Most languages used commercially have only a compiler. POP11 and some versions of LISP and PROLOG use an incremental compilers. TEACH GLOSSARY PAGE 5 Iteration Repeating some action over and over again by means of a loop. In POP11, WHILE, UNTIL, FOR, FOREACH, and FOREVERY are among the available iteration instructions. Invoke See Call. Label Marker that you insert in a procedure at a spot that you want to jump to by using a GOTO statement somewhere else in that procedure. It may be expressed in POP11 by a word followed by a colon. This is very rarely necessary in a high level language, and is best avoided as it usually leads to unclear and non-modular programs. List A sequence of "links", each containing two pointers, a HeaD pointer and a TaiL pointer. The head pointer of the first link points to the first item on the list and the TaiL pointer points to the second link. The second link points to the second item and the third link, and so on. The last link points to the last item and a special item called [], which doesn't point anywhere. Local Sometimes one defines several procedures all of which use the same variable, say X. To prevent these procedures interfering with each other, one can make the variable "local to" these procedures, by writing VARS X; or LVARS X; in all of them. The first makes X a dynamic local variable, the second makes it a lexical local variable. If X is dynamically local to FRED, then whenever FRED is called, the system copies the value of X to a special location, before FRED has a chance to change it, and it reinstates this saved value as soon as FRED is finished. Under such circumstances it is sometimes convenient to talk as if there were several different variables X taking turns at the same "pigeonhole". Any procedure that refers to X non-locally, while FRED is running, will get the local value in FRED not the saved value. If X is lexically local to FRED, i.e. defined using LVARS, then there is no connection at all between X as used in FRED and X as used in any other procedure, whether it is used locally in the other procedure or not. It is as if variables defined using LVARS are given unique private names in the procedure in which they are defined. For more on this see TEACH VARS_AND_LVARS. The formal parameters of a procedure are automatically made local to it. A variable which is not local to a given procedure is said to be global to it. Global variables are useful when you want TEACH GLOSSARY PAGE 6 several different procedures to refer to the same location in memory. Location You can think of computers as made up of numbered slots, called "locations". The number of a location is its address. See variable and pointer. Loop A sequence of instructions to be executed repeatedly by passing control back to its own beginning. (You usually write a loop so that control passes out of it when some condition is satisfied). See Iteration LVARS This, like VARS, can be used to declare variables. However it declares them as lexically scoped, which means that if a variable X is declared in a procedure P using "LVARS X;" then nothing outside P can access that variable. If it declared in a file F, but outside any procedure, then things in the file can access X, but nothing outside that file. For more on this see TEACH VARS_AND_LVARS and HELP LEXICAL. See also VARS Object oriented Object oriented programming languages provide special facilities to support large, complex, extendable programs. Object oriented methodologies analyse programming tasks in such a way as to make them map onto the mechanisms of object oriented languages. POP11 is not intrinsically an object oriented language but it has an extension called "Objectclass" which is object oriented. See TEACH OOP, HELP OBJECTCLASS, and Chapter 9 of the Pop-11 Primer. OOP See Object oriented. Operation or Operator An operation (sometimes called an "operator") is a procedure, but the commands with which you define and call or invoke it conform to a different syntax. Operations are called by just writing their names, without the "." or "()" which ordinary POP11 procedures require. If they are procedures of two arguments, then these can appear on either side of the identifier, as in 2 + 5 which is equivalent to +(2, 5) Another example is list1 <> list2 which is equivalent to TEACH GLOSSARY PAGE 7 <>(list1, list2) Because an operation requiring two arguments can be written between its arguments it is sometimes described as an "infix" operation. Using infix operations without parentheses leaves expressions such as X + Y * Z potentially ambiguous, and so operations are given "precedence" which determines which operation applies first. Operations of lowest precedence are performed first. If the symbol "++" is defined as an operation, identifier then writing X ++ Y is acceptable. If "++" has not been declared as an operation identifier, you'll get an error message 'MISSING SEPARATOR'. Parameter An "actual" parameter of a procedure is simply an argument to which it is applied. The command F(0); calls the procedure F and supplies it with 0 as an actual parameter. A "formal" parameter is needed to describe how a procedure is to be applied to its arguments, i.e. to define the form of the procedure. A "formal" parameter behaves like a variable in which a procedure keeps an argument. If the definition of F is define F (X) -> Y; X * (X + 3) -> Y; enddefine; then the variable X is a formal parameter of F; it is automatically made local to F, as if it were defined inside F using "LVARS X". X is referred to as an "input local" and Y as an "output local". Y is also automatically declared as a local "lvars" variable in F. When F is applied to 0, i.e. when we 'call' F(0), X takes the value 0 for the purposes of the computation. When F runs the value given to X is used to execute the "body" of the procedure, which does some computation and in this case assigns a value to Y, the output local. The value of the output local is left on the stack when the procedure terminates. A procedure may have no formal parameters or several. The formal parameters of a procedure are local to that procedure. See also VARS and LVARS and TEACH STACK, TEACH VARS_AND_LVARS. Pointer A pointer to an object is actually the address of the location of the object, i.e. it is a number as far as the computer is concerned, though you cannot treat it as a number in Pop-11 (as you can in some languages, like C and C++). TEACH GLOSSARY PAGE 8 The way the computer puts a pointer to an object A into a location B is to write the address of A into the location B. See variable and list. Precedence see Operation Procedure The basic unit of program in POP11. In order to make anything happen, you must call (synonyms run, apply, execute, invoke) a procedure. System (or standard) procedures are supplied as part of the language, and you can define further procedures of your own (see DEFINE). Examples of system procedures are LENGTH, HD, TL, PR, +, *, <>. People who use the word "function" instead, often restrict "procedure" to functions that do not produce any results. Recursion In POP11, you can define procedures which call themselves. When they do, it is called recursion. If procedure F calls G and G calls F, that is "mutual recursion". Result When a procedure is executed it may produce results, i.e. leave things on the stack. For example when the procedure HD is applied to the list [4] it produces the result the number 4. If a procedure F produces a result, then it can be used in an assignment statement for example F(X) -> Y; In POP11 a procedure can leave several results on the stack. For example 16//5 leaves both the remainder and the divisor on the stack, after dividing 16 by 5. For example vars R,D; 16//5 -> (R, D); R=> ** 1 D=> ** 3 Run see Call Semantics Roughly another name for "meaning". See syntax. The semantics of POP11 have to do with structures inside a computer and processes involving those structures. Side-effect A procedure can have two kinds of effect. It can TEACH GLOSSARY PAGE 9 straightforwardly leave "results" on the stack and it can also make sneaky changes which do not show up on the stack. For instance, it can change the value of some global variables or the contents of some data structures. These sneaky changes are called side effects. Stack, the A special place in the machine from which procedures take their arguments and where they can leave their results. It is like a stack of blocks in that when you add a new item, it goes on top of whatever is already there, and you have to take off things on top before you can get at the ones underneath. So the first thing to go on is the last to come off, and vice versa. The name of any item followed by a semi-colon or a comma constitutes a command to put the item on the stack. For example 3; puts 3 on the stack. A command of the form F(3); where F is the name of a procedure, may appear to apply the procedure directly to the argument 3, but what really happens is that 3 is the first put on the stack and then F takes it off again. Finally, if F gives results, it puts them on the stack. So the following puts five numbers on the stack. 8, 4, SQRT(2), 3+2; 66; Assignments are used to take things off the stack and put them somewhere else. For example -> Y; -> X; or -> (X, Y); takes the top two things off the stack, and assigns the top item to Y and the next one to X. See also TEACH STACK, TEACH POPCORE. Syntax Roughly, a name for the visible structure of a language, and the rules specifying permitted structures. For example X + 1 -> X Z + 1 -> Y; is not legal POP11 syntax, whereas X + 1 -> X; Z + 1 -> Y; is legal. Tail see List TL POP11 standard procedure which gets hold of the TaiL of a list, and puts a pointer to it on the stack. Variable A variable is a location which has an identifier which refers to it. Sometimes people talk of the identifier as if it were the variable, but strictly speaking they are distinct. A variable is a device for giving a POP11 object a temporary label which you can then use to refer to it. You can think of "the variable X" as a TEACH GLOSSARY PAGE 10 pigeonhole, labelled "X". Assigning the word "cat" to X is done thus: "cat" -> X; Then "X" can be used, temporarily, as a name for 3, for example in [^X is an animal] This is like putting "cat" in the pigeonhole, except that Pop-11 objects, unlike pigeons, can be in more than one pigeonhole. E.g. more than one variable can have the word "cat" as its value. For instance, if we assign the value of X to another variable Y, X -> Y; Then X still has its old value and Y has the same value. So, it is better to think of pigeonholes as containing, not their actual values, but rather pointers to those values. See also Local, Location, Pointer, VARS and Identifiers. Variable binding When you apply a procedure to some arguments, the formal parameters of the procedure are given ("bound to") the arguments as values. Similarly if you assign a value to that variable, then the variable is bound to that value, until you assign a new value to the variables. In the terms used in discussing variables, a new "pointer" is put into the "pigeonhole" corresponding to the parameter. VARS A POP11 word which declares the identifiers that follow it as variables. If the declaration occurs within a procedure definition then the variables are local to that procedure. Compare LVARS. If a declaration includes a system word then an error will result, for example VARS PR; A local variable declared using "VARS" is called a "dynamic" local variable. A variable declared using "LVARS" is a "lexical" local variable. See LVARS. In a VARS declaration if an identifier is preceded with an integer specifying a precedence the identifier is declared as an operation of that precedence, for example VARS 8 ++; declares "++" to be an operation of precedence 8. You can also declare an operation just as you do a procedure, except that an integer precedence follows the word DEFINE. Example: define 7 === (x y); equal (x, y) enddefine; TEACH GLOSSARY PAGE 11 Then you can write: if l === [a happy cat] then ... instead of if equal(l, [a happy cat]) then ... WORD see Identifier. --- $poplocal/local/teach/glossary --- Copyright University of Birmingham 2000. All rights reserved. ------