Guard-based auditing

This is a new design for auditing in E. It is an alternative to the unshadowable-names/synEnv system currently implemented in E-on-Java, and the give-the-auditor-access-to-everything previously used by E-on-CL.

It is currently provided in E-on-CL and User:Markm plans to implement it in E-on-Java.

Basic implementation
In environments, nouns are associated with "bindings" instead of slots. A binding is an object which holds a slot and a guard, and alleges that that slot was returned from that guard (except for object expressions; see below).

These properties of binding objects happen to make them very much like VarSlots except for being immutable, so they implement the slot protocol and are called CoercedSlot. CoercedSlots are PassByConstruction and non-transparent Selfless.

Note that FinalPatterns and VarPatterns must get FinalSlot and VarSlot guards; e.g.  results in the binding object   (except that implementations may optimize it to not require constructing an intermediate FinalSlot if the guard coerces).

If a pattern does not have a guard, then  is used. Examples:  has a binding guard of , and   has a binding guard of.

Environments gain the methods fetchBinding/2, getBindings/0 (returns an object mapping nouns to bindings), and getSlots/0 (returns an object mapping nouns to slots), and lose iterate/1.

Auditions have one relevant method, getGuard/1. Given a noun (string), it returns the guard of the matching binding. If the noun is not one of the free variables of the audition's object expression, or if the audit has already terminated, then an exception is thrown.

An additional component on kernel ObjectExprs: the " " clause, syntactically preceding the " ", behaves like it but with the additional effect of making its value be the guard for the binding of the object name (without coercing the object). That is,  audits x with Y, and also causes the binding to be. In the E AST, the current auditorExprs :List[EExpr] is replaced with a new node type "AuditorExprs" with fields ( as :nullOk[EExpr], implements :List[EExpr]).

Bindings may be reified in E programs using the prefix &amp;&amp; operator. (This is necessary to support nonkernel, and beneficial to the extends-syntax " ".) "&amp;&amp;" is a single token and operator, not two prefix operators. As an expression, it is BindingExpr(NounExpr); as a pattern it is BindingPattern(NounExpr). The pattern does not take a guard like SlotPattern does.

The expansion of ObjectExpr's "extends" clause is changed such that " " results in  defined as " "; if the expression in the extends clause is not a noun then the expansion remains the current " "

Because bindings are Selfless, the evaluator need not make any effort to preserve their identities.

All bindings in the safeScope expose their values in their guards; that is, they are.

CoercedSlots are PassByConstruction; their uncall is makeCoercedSlot.attempt(guard, value). This performs guard.coerce(value, ...); if the guard fails, or returns a reference which is not the same as the original value, then the resulting CoercedSlot has LostApproval[guard] instead of the original guard. LostApproval is equivalent to any, and is used merely to report what the original guard was and why it is missing. 

Implications for guards
To support multiple independently-written auditors on the same object, it must be possible to have single guards which satisfy multiple auditors' criteria. It is also desirable that programmers need not write code to match exactly an auditor's view of what is necessary. Therefore, we add the optional operation rangeSupersetOf/1 to guards.

to rangeSupersetOf(other :Guard) :nullOk[boolean]

If X.rangeSupersetOf(Y) returns true, X is claiming that every value returned by Y (as a guard) would have been returned by X under some circumstances; that is, the 'range' of X is a 'superset of' the range of Y. For example, int.rangeSupersetOf(1..10) should be true, as should DeepFrozen.rangeSupersetOf(int).

Returning false indicates that X is not a range superset of Y; returning null indicates that X doesn't know.