I've mostly completed the data-collection part of the transaction
reports code, and am now figuring out how to implement the formatted
data output.
I'm going over your mail of a few weeks ago, attempting to figure
out how to actually implement this code.
I'd just like some clarifications on a few points and go over some
additions that have occurred to me:
;;; Suggested set of functions to manage report data in a
;;; device-independent manner.
;;; report-string, report-total, report-value are used to output
;;; values. "string" should be obvious; "value" will be a currency
;;; amount, and probably should be currency-aware. "total" allows
;;; a bunch of "values" to be collected into a single total "cell."
;;; The point to totals being distinct from values is that this allows
;;; the total to remain a dynamic calculation if, for instance, output
;;; is going into a spreadsheet.
;;;
;;; (define (report-string string indentation style))
Should be (define (report-string string column indentation style)),
as we have previously discussed.
;;; (define (report-value value collector-thunk column
;;; linkname style))
;;; (define (report-total input-collector-thunk
;;; output-collector-thunk column
;;; linkname style))
1) Could we add a report-date function here?
2) What should these functions return? At this stage, they have to
return some kind of data structure which would probably be a vector
containing
i. the type (ie string, value, total, or date)
ii. the "value"
iii. the linkname
iv. the column
v. the style
Do I understand this correctly?
;;; You pass a list of the thunks established above into (report-line)
;;; which combines them into a single line.
;;; (define (report-line report-port . list-of-thunks))
;;;
1)report-line actually performs the formatting (then sends it to the
appropriate physical port), doesn't it? Would it
make sense here for the report-port data structure to contain a
renderer function that does the transformation of the thunk list into
a string that can then be fed to the physical report port?
2) The use of "thunk" here makes me think I have misunderstood the
return value of report-value and its ilk. A thunk, as I understand
it, is a no-argument function. If I do the following
(define x (list 1 2 3))
Does "x" become a thunk?
(car (cons 2 3))
Is (cons 2 3) a thunk in this context?
could you clarify for me (as a Scheme newbie) what exactly is a thunk?
;;; (define (define-report-total-collector))
;;; define-report-total-collector returns a thunk used by report-value
;;; and report-total to collect together values to establish a "total"
;;; In the case of HTML/Text output forms, this can just grab the
;;; values. In the case of a spreadsheet output form, this would
;;; collect up the cell IDs so that (report-total) would generate a
;;; formula like "=D2+D3+D4+D5+...+D15"
In the spreadsheet case, for instance, the part that prints the
total needs information that will need information that is not known
until all the values that make it up have been rendered. What we need
to generate is a function that gets called when a value is *rendered*
and adds some arbitrary info to a list somewhere. We
also need a corresponding function that returns the completed list
when the total is to be rendered.
Therefore (define (define-report-total-collector)) would return a pair
of functions, one that takes an argument of arbitrary guff to be
stored, one a thunk that returns a list of the guff.
Is this what you had in mind, or have I misunderstood something?
;;; (define (report-start-section report-port linkname))
;;; (define (report-end-section report-port))
;;; These functions are necessary for the HTML output form to generate
;;; the table start/end info. It would not be a bad move to change
;;; this to:
;;; (define (report-start-section report-port linkname . list-of-thunks))
;;; that works like (report-line), so that the first line in the table
;;; can contain header data.
I like the second option.
;;; style:
(define style-structure
(make-record-type
"style"
'(alignment fontinfo color)))
I still have concerns that allowing ourselves more than a fixed set
of styles that we can implement in all output forms is just going
to make life too hard.
Can you suggest how your method might be implemented in a portable fashion?
The rest of it looked fine (but, to be honest, I haven't gotten
as far as thinking about how the rest might be implemented).
Clarification of the above would be much appreciated.
--
---------------------------------------------------------------------------
Robert Merkel [EMAIL PROTECTED]
Humanity has advanced, when it has advanced, not because it has been sober,
responsible, and cautious, but because it has been playful, rebellious, and
immature.
-- Tom Robbins
---------------------------------------------------------------------------
--
Gnucash Developer's List
To unsubscribe send empty email to: [EMAIL PROTECTED]