codesimian
Class TypeCheckedList

java.lang.Object
  extended by codesimian.CS<CSGeneric>
      extended by codesimian.DefaultCS
          extended by codesimian.SimpleList
              extended by codesimian.TypeCheckedList
All Implemented Interfaces:
CodeSimian

public class TypeCheckedList
extends SimpleList

can only contain CSs that are the correct TYPE. Returns false if you try to add anything else. Type is defined by PType(int) for each param index, and is set by setPType(int,CS).

Example codesimian code:
do(
        typeCheckedList#theList(0 1 2 +(1 1 1) 4)
        func#typeChecker(0#x ==I(countP(x) 3)) "only accept things with 3 params"
        setPType(theList 3 typeChecker) "only allow things with 3 params in position 3"
        setP#work(theList 3 *(2 3 4)) "this should work because countP(*(2 3 4)) is 3"
        setP#fail(theList 3 *(2 3 4 5)) "this should fail because countP(*(2 3 4 5)) is 4"
        print("\nshouldWork = ") printD(work)
        print("\nshouldFail = ") printD(fail)
)


Field Summary
 
Fields inherited from class codesimian.CS
DESCRIPTION, END, EXECPROXY, HEAP, JAVACODE, MYFUEL, NAME, NEWINSTANCE, NULL, PARENT, PARSEPRIORITY, PREV, TESTER, THIS
 
Constructor Summary
TypeCheckedList()
           
 
Method Summary
 java.lang.String keyword()
          For the CodeSimian language as a String.
CodeSimian language keyword, like "+" "*" "max" ">" etc.

Override this function if you want to specify a keyword other than how I derive them from the class name, like + for Add.

Some CSs might never be intended to be used in the language by their keyword.
The best example (4/05) is Num, because it is used in the language like "3.4" instead of "num()".
 CS PType(int index)
          There is a TYPE for each Param.
A TYPE is a CS whose minP() is at least 1.
 boolean setP(int index, CS value)
          Every CS is a list of other CSs, between size minP() and maxP() inclusive.
 boolean setPType(int index, CS newTypeOfThatParam)
          Since only a small fraction of CSs use types other than the default type, setPType(int,CS) returns false by default.
 
Methods inherited from class codesimian.SimpleList
DForProxy, maxP, minP
 
Methods inherited from class codesimian.DefaultCS
B, C, countP, decrementMyFuel, deleteP, description, F, fuel, getExec, getObject, heap, I, indexP, indexPName, insertB, insertC, insertD, insertF, insertI, insertJ, insertL, insertL, insertL1, insertP, insertS, insertZ, J, javaCode, LForProxy, LForProxy, myFuel, name, newInstance, objectToCS, objectToCSArray, objectToCSArray, P, prevD, prevL, S, setB, setC, setCountP, setD, setD, setExec, setF, setFuel, setI, setJ, setL, setL, setL, setL1, setMyFuel, setName, setObject, setPrevExec, setS, setZ, start, toString, V, Z
 
Methods inherited from class codesimian.CS
addB, addC, addD, addF, addI, addJ, addL, addP, addP, addP, addP, addP, addS, addZ, BForProxy, CForProxy, clone, cost, D, deleteP, FForProxy, GETB, GETC, GETD, GETF, GETI, GETJ, GETL, GETS, GETZ, IForProxy, isIllusion, JForProxy, L, L, L, L, L, maxD, minD, overwrites, parent, parsePriority, PB, PC, PD, PF, PI, PJ, PL, prevB, prevC, prevF, prevI, prevJ, prevS, prevZ, proxyOf, PS, PZ, reflect, reflect, reflect6, setB, SETB, setC, SETC, setCost, SETD, setDescription, setF, SETF, setHeap, setI, SETI, setJ, SETJ, SETL, setL, setL, setParent, setParsePriority, setProxyOf, setS, SETS, setTester, setZ, SETZ, SForProxy, tester, toJavaCode, VForProxy, voidReflect, ZForProxy
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TypeCheckedList

public TypeCheckedList()
Method Detail

setP

public boolean setP(int index,
                    CS value)
Description copied from class: CS
Every CS is a list of other CSs, between size minP() and maxP() inclusive. setP overwrites one of those CSs or adds a new one at the end, depending on the index. If index is between 0 and countP()-1, overwrites. If it equals countP(), adds at end.

Overrides:
setP in class DefaultCS

setPType

public boolean setPType(int index,
                        CS newTypeOfThatParam)
Description copied from class: CS
Since only a small fraction of CSs use types other than the default type, setPType(int,CS) returns false by default. The same is true of many other functions of CS, which may choose not to cooperate.

Overrides:
setPType in class DefaultCS

PType

public CS PType(int index)
Description copied from class: CS
There is a TYPE for each Param.
A TYPE is a CS whose minP() is at least 1. When a TYPE executes, it MEASURES THE TYPE OF its first param CS. It returns a positive number if it is that type, else 0 or negative. Some TYPEs use only 2 numbers, while others can return any number in a continuous range.

Types are optional. To not use types, return the default type: Static.defaultType(). The default type returns true for any CS. Most CSs do not need types therefore they use the default type.

Overrides:
PType in class DefaultCS

keyword

public java.lang.String keyword()
Description copied from class: DefaultCS
For the CodeSimian language as a String.
CodeSimian language keyword, like "+" "*" "max" ">" etc.

Override this function if you want to specify a keyword other than how I derive them from the class name, like + for Add.

Some CSs might never be intended to be used in the language by their keyword.
The best example (4/05) is Num, because it is used in the language like "3.4" instead of "num()".
Default: Returns class name, minus package name (and its dots), and change the first letter to lowercase.

For example, CS.MaxParams does not override keyword(), which returns "maxP".

Overrides:
keyword in class SimpleList
See Also:
CS.parent(), CS.newInstance(), CS.name()