Basic
Standard Bindings
The Basic form provides the following standard bindings:
returns | service | description |
String | asString(aForm) |
Returns a string representation of aForm. This
representation is determined in the following way:
|
Boolean | false | The boolean value false. |
Form | if(aBoolean)(cases) | If aBoolean is true, then cases.then() is called and it's result is returned. If aBoolean is false, cases.else() is called and it's result is returned. |
Boolean | isEmpty(aForm) | Returns true if aForm is empty, otherwise returns false. |
Boolean | isService(aForm) | Returns true if aForm is a closure, otherwise returns false. |
Empty / Label | label(aForm) | Returns a first class label representing a label of aForm, if aForm is not empty. If aForm is empty, the empty form is returned. |
Form | load(anURL)(aForm) | Loads a Piccola script from anURL and executes it in the context specified by aForm. Returns the value of the script. |
Form | loadCore(aString)(aForm) | |
Form | loadRelative(aString)(aForm) | |
Blackboard | newBlackboard() | Returns a new blackboard. |
Label | newLabel(aString) | Returns a new first class label representing the label specified with aString. |
Variable | newVar(aForm) | Returns a new variable having aForm as it's current value. |
Empty | print(aForm) | Prints asString(aForm) to a console. |
Empty | println(aForm) | Prints asString(aForm) followed by a newline to a console. |
MetaForm | protect(aForm) | Returns a meta-form representing aForm. |
Boolean | true | The boolean value true. |
JPiccola
In JPiccola, the Basic form additionally provides the following bindings:
Form | execNative(cases)(aForm) | Calls cases.java(aForm) and returns the resulting value. |
Form | loop(args) | As long as args.while() evaluates to true, args.do() is called. |
Examples
abs aNumber: if (aNumber > 0) then: aNumber else: -aNumber abs 2 # returns 2 abs -2 # returns 2 sum = newVar 0 i = newVar 1 loop while: *i <= 10 do: sum <- *sum + *i, i <- *i + 1 *sum # returns 55 (sum of 1 to 10)