PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/interpreter/tags/reactive-pattern-matching/src/edu/vub/at/objects/ATBoolean.java

http://ambienttalk.googlecode.com/
Java | 131 lines | 12 code | 11 blank | 108 comment | 0 complexity | cf64fe6cc40948539e7db22327ce4198 MD5 | raw file
  1/**
  2 * AmbientTalk/2 Project
  3 * ATBoolean.java created on Jul 26, 2006 at 9:53:31 PM
  4 * (c) Programming Technology Lab, 2006 - 2007
  5 * Authors: Tom Van Cutsem & Stijn Mostinckx
  6 * 
  7 * Permission is hereby granted, free of charge, to any person
  8 * obtaining a copy of this software and associated documentation
  9 * files (the "Software"), to deal in the Software without
 10 * restriction, including without limitation the rights to use,
 11 * copy, modify, merge, publish, distribute, sublicense, and/or
 12 * sell copies of the Software, and to permit persons to whom the
 13 * Software is furnished to do so, subject to the following
 14 * conditions:
 15 *
 16 * The above copyright notice and this permission notice shall be
 17 * included in all copies or substantial portions of the Software.
 18 *
 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 21 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 23 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 26 * OTHER DEALINGS IN THE SOFTWARE.
 27 */
 28package edu.vub.at.objects;
 29
 30import edu.vub.at.exceptions.InterpreterException;
 31
 32/**
 33 * The ATBoolean represents the public interface of a boolean object.
 34 * 
 35 * @author smostinc
 36 * @author tvcutsem
 37 */
 38public interface ATBoolean extends ATObject {
 39
 40	/**
 41	 * Returns an ATObject representing the result of evaluating the code to execute
 42	 * if the boolean condition is true. Returns nil if the boolean expression is false.
 43	 * <p>
 44	 * Usage:
 45	 * <code>booleanCondition.ifTrue: { code }</code>
 46	 *  
 47	 * @param consequent a closure containing the code to execute if the boolean is true.
 48	 * @return the result of evaluating the closure or nil.
 49	 * @throws InterpreterException if raised in the evaluation of the closure. 
 50	 */
 51	public ATObject base_ifTrue_(ATClosure consequent) throws InterpreterException;
 52	
 53	/**
 54	 * Returns an {@link ATObject} representing the result of evaluating the code to execute
 55	 * if the boolean condition is false. Returns nil if the boolean expression is true.
 56	 * <p>
 57	 * Usage:
 58	 * <code>booleanCondition.ifFalse: { code } </code>
 59	 *  
 60	 * @param alternative a closure containing the code to execute if the boolean is false.
 61	 * @return the result of evaluating the closure or nil.
 62	 * @throws InterpreterException if raised in the evaluation of the closure. 
 63	 */
 64	public ATObject base_ifFalse_(ATClosure alternative) throws InterpreterException;
 65	
 66	/**
 67	 * Returns an {@link ATObject} representing the result of evaluating either the code to execute
 68	 * if the boolean condition is false or the one to execute if the boolean condition is true.
 69	 * <p>
 70	 * Usage:
 71	 * <code>booleanCondition.ifTrue: { consequent } ifFalse: { alternative } </code>
 72	 *  
 73	 * @param consequent a closure containing the code to execute if the boolean is true.
 74	 * @param alternative a closure containing the code to execute if the boolean is false.
 75	 * @return the result of the consequent or alternative closure. 
 76	 * @throws InterpreterException if raised in the evaluation of the consequent or alternative closure. 
 77	 */	
 78	public ATObject base_ifTrue_ifFalse_(ATClosure consequent, ATClosure alternative) throws InterpreterException;
 79	
 80	/**
 81	 * Returns false if the receiver is false or the result of the evaluation of the other
 82	 * boolean expression passed as argument if the receiver is true.
 83	 * <p>
 84	 * Usage: <code>boolean.and: { other }</code>
 85	 *  
 86	 * @param other a closure whose evaluation returns a boolean.
 87	 * @return false or the result of evaluating the other boolean. 
 88	 * @throws InterpreterException if raised in the evaluation of the other boolean. 
 89	 */
 90	public ATBoolean base_and_(ATClosure other) throws InterpreterException;
 91	
 92	/**
 93	 * Auxiliary function:
 94	 * <code>
 95	 * def boolean.and: b1 and: b2 {
 96	 *   (boolean.and: b1).and: b2
 97	 * }
 98	 * </code>
 99	 */
100	public ATBoolean base_and_and_(ATClosure b1, ATClosure b2) throws InterpreterException;
101	
102	/**
103	 * Returns true if the receiver is true or the result of the evaluation of the other
104	 * boolean expression passed as argument if the receiver is false.
105	 * <p>
106	 * Usage: <code>boolean.or: { other }</code>
107	 *  
108	 * @param other a closure whose evaluation returns a boolean.
109	 * @return true or the result of evaluating the other boolean. 
110	 * @throws InterpreterException if raised in the evaluation of the other boolean. 
111	 */
112	public ATBoolean base_or_(ATClosure other) throws InterpreterException;
113	
114	/**
115	 * Auxiliary function:
116	 * <code>
117	 * def boolean.or: b1 or: b2 {
118	 *   (boolean.or: b1).or: b2
119	 * }
120	 * </code>
121	 */
122	public ATBoolean base_or_or_(ATClosure b1, ATClosure b2) throws InterpreterException;
123	
124	/**
125	 * Returns true if the receiver is false or false if the receiver is true.
126	 *  
127	 * @return a boolean resulting of the negation of the receiver. 
128	 */
129	public ATBoolean base_not() throws InterpreterException;
130	
131}