APLX Help : Help on APL language : APL Fundamentals : The Workspace
|
|
![]() |
The Workspace |
The workspace is a fundamental concept in APL. It enables you to develop a project as a series of small pieces of program logic. These are organized into functions, operators and classes, as described below. (For brevity, we sometimes use the term 'function' in this discussion to refer to all three of these). All of these co-exist in the workspace and are instantly available for inspection, amendment, and execution - or for use on another project. Data of all shapes and sizes (stored in variables) can inhabit the same workspace as the functions, and is also instantly available, which greatly facilitates testing. And, of course, the entire collection can be saved on to disk by a single command or menu option. Functions, operators, and classes can quickly be constructed, tested, strung together in various combinations, and amended or discarded. Most importantly, it is very easy in APL to create test data (including large arrays), for trying out your functions as you develop them. Unlike many traditional programming environments, you do not need to compile and run an entire application just to test a small change you have made - you can test and experiment with individual functions in your workspace. This makes the workspace an ideal prototyping area for 'agile development', and helps explain why APL is sometimes referred to as a 'tool of thought'. Functions, Operators, ClassesIn APL, the term function is used for a basic program module. Functions can either be built-in to the APL interpreter (for example, the + function which does addition), or defined by the user as a series of lines of APL code. Functions can take 0, 1 or 2 arguments. For example, when used for addition + takes two arguments (a left argument and a right argument). The arguments to functions are always data (APL arrays). Functions usually act on whole arrays without need for explicit program loops. An operator is like a function in that it takes data arguments, but it also takes either one or two operands which can themselves be functions. One of the commonly-used built-in operators is Each ( A class is a collection of functions and possibly operators (together known as methods), together with data (placed in named properties of the class). A class acts as a template from which you can create objects (instances of classes), each of which can have its own copy of the class data, but which shares the methods with all other instances of the class. A class can be used to encapsulate the behavior of a specific part of your application. Workspace sizeThe workspace size is stated on the screen when you start an APL session. Depending on the workspace size, it is either expressed in 'KB' 'MB' or 'GB', where:
During the session you can find out how much space is free by using the system function The maximum size of the workspace depends on how much memory (RAM) you have on your system, and the amount of disk space reserved for virtual memory. Managing the workspaceThere are system commands for enquiring about the workspace and doing operations that affect it internally. The most useful of these are mentioned below under the heading 'Internal workspace commands'. (Note that, to distinguish them from names in your program, the names of system commands start with a right parenthesis.) There are also system commands for copying the current workspace to disk, reloading it into memory and doing other similar operations. These are mentioned below under the heading 'External workspace commands'. You can either type these commands directly, or (on most versions of APLX) use the File menu to load and save workspaces. Internal workspace commandsAt the start of a session, you're given an empty workspace which has the name You can get a list of the variable names in the workspace by using the If you don't want to clear the entire workspace, you can get rid of individual items by using the command External workspace commandsNote: In practice, you will often use menus to load and save workspaces, rather than typing the system commands described below. For example, rather than typing A collection of workspaces on a disk, or other storage medium, is a library. (It corresponds to a directory or folder in the host operating system). Unless you change the library number associated with each device, the device listed first when you type Library 10 is a special case. It contains the utility workspaces and examples supplied as part of the APLX installation. The use of library numbers is a convenience which helps you organize your workspaces on disk, and saves you from having to enter long path names when referring to them. But if you prefer, you can enter the full path name to a workspace when you load and save it (or use the File menu). To find out the names of the workspaces which you have already stored in library 0, use the command You can save the current workspace by simply issuing the command: The If you want to bring specific functions or variables into memory, but don't want to overwrite the workspace already there, you can use the You can get rid of a workspace on a disk by using the System variablesWhat goes on in the workspace is conditioned to some extent by the current settings of system variables. These are built-in variables, whose names begin with ' Some system variables you may occasionally want to enquire about or (in some cases) alter are:
You can find out the value of a system variable by typing its name. For example, to see the setting of ⎕PP 10 You can reset the value of most system variables by using the symbol ⎕PP ← 6 System functionsWe've been discussing system variables. System functions can also affect your working environment. The system function Other system functions duplicate tasks performed by system commands. For example, the system function The difference between system functions and system commands is that system functions are designed for use in user-defined functions, and behave like other functions in that they return results which can be used in APL statements. System commands, on the other hand, are primarily designed for direct execution and can only be included in a user-defined function if quoted as the text argument to the function There are many System Functions and Variables available in APLX. They have other purposes besides control of the workspace; for example they are used for reading and writing files, and for accessing databases, and for doing string-searches using regular expressions. |
|
APLX Help : Help on APL language : APL Fundamentals : The Workspace
|
Copyright © 1996-2010 MicroAPL Ltd