diff --git a/.gitignore b/.gitignore index 97dcc39..0bd6ac3 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ bbstool-static *.c output/ members/ +hackerbase diff --git a/src/bank-account.scm b/src/bank-account.scm index 29f3c71..8cbc9f9 100644 --- a/src/bank-account.scm +++ b/src/bank-account.scm @@ -51,7 +51,11 @@ (import scheme (chicken base) - (chicken format)) + (chicken format) + util-tag) + + ;; Unique tag + (define TAG-BANK-TRANSACTION (make-tag bank-transaction)) ;; Bank account is represented as a list with list with the following ;; elements: list of transactions, account number, bank code. This @@ -74,20 +78,39 @@ (cons (cons transaction (car account)) (cdr account))) - ;; Creates a new bank transaction. - (define-record bank-transaction id date amount currency varsym message type account bank specsym) + ;; Creates new record + (define (make-bank-transaction . args) + (apply vector (cons TAG-BANK-TRANSACTION args))) - (set-record-printer! bank-transaction - (lambda (tr out) - (fprintf out "#" - (bank-transaction-id tr) - (bank-transaction-date tr) - (bank-transaction-amount tr) - (bank-transaction-currency tr) - (bank-transaction-varsym tr) - (bank-transaction-message tr) - (bank-transaction-type tr) - (bank-transaction-specsym tr)))) + ;; Defines one accessor + (define-syntax define-accessor + (syntax-rules () + ((_ num) + (void)) + ((_ num acc accs ...) + (begin + (define (acc t) + (vector-ref t num)) + (define-accessor (add1 num) accs ...))))) + + ;; Defines all accessors + (define-syntax define-accessors + (syntax-rules () + ((_ accs ...) + (define-accessor 1 accs ...)))) + + ;; Define accessors for bank-transaction + (define-accessors + bank-transaction-id + bank-transaction-date + bank-transaction-amount + bank-transaction-currency + bank-transaction-varsym + bank-transaction-message + bank-transaction-type + bank-transaction-account + bank-transaction-bank + bank-transaction-specsym) ;; Returns true if given acc/bc is in the list of accounts (define (bank-accounts-member? bas acc bc)