org.erights.e.elib.slot
Interface ValueGuard

All Known Subinterfaces:
Guard
All Known Implementing Classes:
BaseGuard, ConstList

public interface ValueGuard

Untamed: A ValueGuard will either coerce an input to a value that matches some condition, or it will fail. A ValueGuard is used in the E language to guard the return value of a method. It is also used both in E and ELib as an argument to a SlotGuardTemplate and a ValueGuardTemplate.

Author:
Mark S. Miller

Method Summary
 Object coerce(Object specimen, OneArgFunc optEjector)
          Enabled: If specimen coerces to a value that matches the condition represented by this guard, return that value; other fail (according to optEjector) with a problem explaining why not.
 String getName()
          Enabled: All E guards should respond to "getName()"
 

Method Detail

coerce

public Object coerce(Object specimen,
                     OneArgFunc optEjector)
Enabled: If specimen coerces to a value that matches the condition represented by this guard, return that value; other fail (according to optEjector) with a problem explaining why not.

If optEjector is null, then throw the problem. Otherwise, call optEjector with the problem. optEjector should perform a non-local exit, and so should not return. If optEjector returns anyway, then throw the problem after all.

A note to Java implementors of this method: You almost certainly want to start your method with

    specimen = Ref.resultion(specimen);


getName

public String getName()
Enabled: All E guards should respond to "getName()"



comments?