UP

General Points

The space bank transformer will accept a space bank and produce a new space bank with different properties. It will also verify that a key is a space bank. The space bank transformer is prompt. For a more detailed description of space banks and the space bank transformer, refer to the defining document in Algol68.

{arcane}{nonref}Design notes: We may delete the concept of space bank transformer and define calls on the space bank to do the transforming. This would mean that some programs would not need to hold a transformer key. We may further define a call on a bank passing another bank for the verify function. When a bank is passed to you, you ask a bank that you already know and trust whether the new bank is as good. This change would permit the other programs to not hold transformer keys. Warning: the space bank used by the space bank transformer must not attempt to call the space bank transformer or a deadlock will result.

We propose to add a transformation that would cause a transformed bank to produce only gratis nodes etc.

SBT(0;B==>c;) {"verify"}.

If B is not an official space bank, c will be -1. If B is an official bank then bit 0 of c is 0 and c will be P + Q + D + L. If B is prompt P is 0 otherwise 128. If B has query rights Q is 0 otherwise 2. If B has destroy rights D is 0 otherwise 1. If B has limit set rights L is 0 othewise 4.

SBT(kt;==>c;) returns X'040C' in c.

In all the operations below, if B1 is not an official space bank, c will be 3. If the operation is successful, c will be 0 and B3 will be the only key to a new official space bank. Account AC will pay rent for the new bank until the bank is destroyed. The bank will be destroyed as soon as AC is either exhausted or not an account. {The bank can also be destroyed explicitly.} A prompt bank remains prompt when destroyed. Unless otherwise specified, the new bank will be prompt iff B1 is. B3 has destroy and query rights.

SBT(1,((4,lower_node_limit), (4,upper_node_limit), (4,lower_page_limit), (4,upper_page_limit));B1,,AC==>c;B3) {"select subrange"}.

The new bank will have the same properties as B1 except that nodes and pages created with the new bank have CDA's that are restricted to a subrange of the range of B1. The lower and upper limits are relative to the range of B1. If a limit is not specified, the subrange is not restricted from that side. If a call to the new bank is unsuccessful because there was no space in the indicated range, it will return with a return code of 1.

SBT(2;B1,,AC==>c;B3,,G) {"guard only"}.

The new bank is like B1 and has no special functions. It can be used to provide a point for keeping statistics, or for using the "destroy and zap space" operation, or for compatibility with an older implementation which provided the key G.

{obsolete}G is the "guardian".

G(64;==>c;) {"destroy and zap space"} is the same as B3(64;==>c;).

{obsolete}G(0;==>;) sets a flags such that when the bank is destroyed, the space created under it is also destroyed, as though by B3(64;)

{obsolete}G(1;==>0;) does the same as B3(kt+4;==>0;).

For X from 2 through 31, G(X...) does the same as B3(X...).

G(kt+4;==>0;){"Destroy"} does the same as B3(kt+4;==>0;).

G(kt;==>c;) returns in c X'01040C'.

{ni}SBT(3;B1,B2,AC==>c;B3) {"amalgamate"}.

If B2 is not an official space bank c will be 4. The new bank will have the following properties. It will be prompt iff B1 and B2 both are. When requested for space, B3 will call B1; if that call is successful, B3 returns the result to its caller. If it is unsuccessful {i.e., returns a nonzero order code}, B3 calls B2 and returns its result. B3 remembers which bank the keys it gives out came from. It uses AC to pay for space to store this information, i.e. the rent will have a term that is proportional to the number of keys that have been created. On calls to B3 that pass a node or page key, B3 calls the bank that the key came from and returns its result.

B3 is not considered a sub-bank of B1 or B2 in the following sense. B3 isn't destroyed when B1 or B2 is.

Implementation note:

To support the "destroy and zap space" operation, a key to space created under B3 will have to be saved by both B3 and the bank it came from {B1 or B2}.

Note: Current designs require that B3 be prompt if either B1 or B2 is. It must fork to both banks. This is so that dismounting a disk needn't bring everything to a stop. Perhaps this can be another type of amalgamated bank.

{ni}SBT(4;B1,E,AC==>c;B3) {"divert error return"}.

The new bank will be like B1 except that if a call to B3 is unsuccessful, instead of returning an error code it calls key E with the same parameters as the call to B3 except that the {4-byte} error code will be inserted at the front of the byte string. If E returns with a nonzero order code the operation is attempted again. If E returns with a zero order code the original error code is returned to the caller of B3. The new bank is not prompt.

{nonref}Programming note:

A program with a space bank may pass it to a gate, which passes it to another, until the program which actually uses the bank to get space is reached. The original program often does not know in advance how much space will be required. If more space is required than anticipated the program may wish to make more space available, then resume the operation. For example, it may ask a user at a terminal whether he wants to delete any old files. It would be awkward if, when the bank ran out, an error were returned all the way back to the original program; when space was recovered, it might be difficult or impossible to resume at the point where the error occurred.

The purpose of the "divert error return" transformation on a node or page bank is to permit this situation to be handled gracefully.

However, for some purposes a space bank which is prompt is required, and a bank with diverted error return is not prompt. In every case where a prompt bank is required, a bound is given on the amount of space which is needed from the bank. If a program wishes to recover from the possibility of not having enough space in such a situation, it must ensure before it passes the {prompt} bank that the bank has at least the required {bounded} amount of space.

SBT(5,((4,node_limit), (4,page_limit));B1,,AC==>c;B3) {"limit space"}.

The new bank will be like B1 except that nodes and pages are accounted for as follows. Node_limit is a limit on the number of nodes that can be created. If the limit would be exceeded, B3 returns with an order code of 4. When a node is returned to this bank the limit is replenished. Similarly for pages.

{ni}SBT(6,((4,node_price), (4,page_price));B1,T,AC==>c;B3) {"account for space"}.

The new bank will be like B1 except that nodes and pages are accounted for as follows. Key T is called to collect for creating a node as follows: T(0,((4,node_price));AC2==>c;) where AC2 is the second key parameter in the create call on B3. {Normally T is an account.} If this call returns c nonzero then the attempt to create is unsuccessful and B3 returns with an order code of 4. When a node is destroyed, a refund is made: T(0,((4,-node_price));AC2==>;). Similarly for pages. The new bank is not prompt.

{ni}SBT(7,((4,node_limit), (4,page_limit));B1,,AC==>c;B3) {"limit gratis space"}.

The new bank will be like B1 except that gratis nodes and pages are accounted for as follows. Node(page)_limit is a limit on the number of gratis nodes {pages} that can be created. Making a node {page} gratis also counts against the limit. If the limit would be exceeded, B3 returns with an order code of 3.

{ni}SBT(8,((4,node_price), (4,page_price));B1,T,AC==>c;B3) {"account for gratis space"}.

The new bank will be like B1 except that gratis nodes and pages are accounted for as follows. Key T is called to collect for creating a gratis node or page or for making one gratis, as described above under "account for space". If the attempt to collect is unsuccessful B3 returns with a return code of 3. A refund is made when a gratis node or page is destroyed or made non-gratis. The new bank is not prompt.

{ni}SBT(9;B1,AC2,AC==>c;B3) {"pre-pay"}.

The new bank will be like B1 except that the second key parameter to B3 will be ignored and AC2 used instead.