Do not use records to aid with serialization in the future.
This commit is contained in:
parent
c13db943b5
commit
9107d33eac
2 changed files with 38 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,3 +8,4 @@ bbstool-static
|
|||
*.c
|
||||
output/
|
||||
members/
|
||||
hackerbase
|
||||
|
|
|
@ -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 "#<transaction ~A ~A ~A ~A ~A ~A ~A ~A>"
|
||||
(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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue