Help with toy example

127 views
Skip to first unread message

Saul Hazledine

unread,
Feb 7, 2011, 6:49:56 AM2/7/11
to Functional Relational Programming
Hello,
I just read the paper "Out of the Tar Pit" and tried an extremely
simple example to improve my understanding. My example is a bank
account which consists of transactions which can have a positive
amount (deposit) or a negative amount (withdrawl):

# User defined Types #

def alias whom : string

# Essential State #

def relvar Transaction :: {amount: number, date: date, who whom}

# External Relations #

Balance = sum(project(Transaction, amount))

# Accidental State #

declare store Balance

I have the following questions about the example above.
1. Is the example idiomatic/correct?
2. In an ideal implementation would the entire balance need to be
recalculated every time a user requests it and its not available in
cache OR could an ideal system be allowed to infer that:

Balance += project(a_new_transaction, amount)

The reason I ask is that a simple running total is obviously mutable
state but is optimal in terms of performance.

Thanks in advance for any help.
Saul Hazledine
Reply all
Reply to author
Forward
0 new messages