function tables

source | test results

Function tables are inspired by script tables in a way. However, they are slightly different, in that they don't really need to be invoked on a specific class. You simply invoke functions. The conventions are as follows:

We learned about page state when studying decision tables. The function table operates slightly differently in that the current-state is passed into each function, and is updated with the results of that function. This data can then continue to wind through other tables, allowing for interesting effects.

Here's an example, using the same banking namespace we found in the decision table type.

some banking
{:alice 0fcae158-c1d7-4eb1-8d2a-aed5e5722b6d}add-user:balance25:nameAliceid?
{:stephen f2a96c1a-2ef4-47c3-af78-33b511b4cb3c}add-user:balance5:nameStephenid?
30.0update-balance:id:alice => 0fcae158-c1d7-4eb1-8d2a-aed5e5722b6d:amount5balance?
20.0update-balance:id:alice => 0fcae158-c1d7-4eb1-8d2a-aed5e5722b6d:amount-10balance?
35.0update-balance:id:alice => 0fcae158-c1d7-4eb1-8d2a-aed5e5722b6d:amount15balance?
10.0update-balance:id:stephen => f2a96c1a-2ef4-47c3-af78-33b511b4cb3c:amount5balance?
update-balance:id:larry => null:amount25balance?
Aliceget-user:id:alice => 0fcae158-c1d7-4eb1-8d2a-aed5e5722b6dusername?
Stephenget-user:id:stephen => f2a96c1a-2ef4-47c3-af78-33b511b4cb3cusername?
nothin'E[clojure.lang.ExceptionInfo: Function not found {:f-name "missing-function"}]
E[clojure.lang.ExceptionInfo: No function specified {}]
A full banking suite (function:)
create a dream
Updating a dream to add a friend (function: client=1 dream-id=:dream-id1)