Reporting system - declarative
Yawar Amin
yawar.amin at gmail.com
Sat Jul 9 18:05:48 EDT 2011
Hi John,
On 2011-07-08, at 23:33, John Ralls wrote:
>> […]
>
> Fun. Two questions: Can that be easily converted into a string parser so that normal users aren't put off by the extra parentheses,
I guess we could replace all the parens with more HTML-reminiscent characters like << and >>, so you’d get stuff like (btw I’m using dots to represent spaces everywhere as my MUA is eating up the first blank space on every line):
<<report ...
..<<defs
....<<def-date ...>>
....<<def-date ...>>
..>>
>>
then do a search-and-replace to turn that back into Scheme. We might overcome a lot of phobia if we hide the fact that we’re really making them write Scheme :-)
Another thing we could recommend is lining up the parens below the function names on multi-line function calls. I mean:
(report ...
..(defs
....(def-date ...)
....(def-date ...)
..)
)
In the beginning I found it a lot more digestible when I didn’t have to deal with the mess of ‘)))))))’.
> and is there anything about that that works in Scheme but not in C?
I really, really don’t want to deal with memory management….
Anyway, I kind of mercilessly hacked the ‘Hello, World’ report that comes with GC, in share/gnucash/guile-modules/gnucash/report/hello-world.scm, and wrote a few functions which do what I was talking about. So now I’m able to say:
(d:report
"income-statement" ; name
0 ; defs
; Have to keep this title while experimenting in the sample report that
; comes with GnuCash
"Hello, World" ; title
"2011-01-01 to 2011-07-31" ; subtitle
(d:filter-none ; body
(d:p "Some text.”)
(d:p "A little more text.")))
… and that generates the report that you’d expect. The ‘d:’ (‘declarative’) prefix is just to make sure I don’t clash with anything. Code is up on https://github.com/yawaramin/gc-decl-reports (I'm not pushing anything which causes a crash for me, so it should be reasonably safe. But caveat emptor).
Regards,
Yawar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
URL: <http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20110709/191ae760/attachment.sig>
More information about the gnucash-devel
mailing list