source: project/gazette/src/issues/21.wiki @ 25558

Last change on this file since 25558 was 25558, checked in by mario, 8 years ago

gazette issue 21: added link to chicken-hackers

File size: 35.1 KB
Line 
1((title . "Issue 21")
2 (authors "Andy Bennett")
3 (date . 1321465864))
4
5== 0. Introduction
6
7Welcome to the 21st issue of the Chicken Gazette. While the gazette
8was on hiatus the chicken community was definitely not.
9
10With the stabilisation of Chicken 4.7 well underway since the last
11gazette...
12
13Some people have also started to set up salmonella farms and C-Keen
14has completed his "Chicken Zoo".
15
16Enjoy!
17
18
19== 1. Chickens Out & About
20
21=== Nuremberg (December 2011)
22[[http://wiki.call-cc.org/users/christian-kellermann|Christian Kellermann]] wrote
23([[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00114.html|2011/10/22 17:38Z]]) to
24confirm the planned Chicken Hacking Sprint scheduled for the beginning of December.
25
26Interested and available Chickenauts will meet in Nuremberg on the weekend of 9th, 10th and 11th
27of December. If you haven't done so already, you can let us know that you will be joining us by
28placing a note at the foot of the [[https://wiki.call-cc.org/chicken-sprint-nuremberg|wiki page]].
29If you can't attend in person then we'll be keeping an eye on IRC so feel free to book yourself
30a slot in your cave at home and join us throughout the weekend and into the evenings, Central European Time.
31
32For those of you keeping score, this will bring the total number of Chicken meets this year to
335 (FOSDEM, Cologne, FrOSCon, T-DOSE and Nuremberg).
34
35
36=== Cologne (March 2011)
37
38In March, Chickens met up at the Chaos Computer Club in Cologne, Germany for a Chicken Hacking Weekend. Here's
39[[http://wiki.call-cc.org/users/moritz-heidkamp|Moritz Heidkamp]]'s report on what they got up to.
40
41The usual suspects [[user:peter-bex|Peter Bex]],
42[[user:felix-winkelmann|Felix Winkelmann]],
43[[user:christian-kellermann|Christian Kellermann]] and me met for two
44and a half days of exchanging ideas and hacking. While we also fixed a
45good share of bugs our main goal for this weekend was to create a
46working prototype of a distributed egg system. By the end of Sunday,
47mostly thanks to Peter's effort, we had something that was already
48pretty similar to what is in use today (see
49[[http://lists.nongnu.org/archive/html/chicken-users/2011-03/msg00160.html|his announcement on the mailing list]]). Apart
50from that some interested visitors stopped by every now and then. Some
51nice chats, food and the occasional beers were had which hopefully
52helped to spread the Chicken word.
53
54
55=== FrOSCon (August 2011)
56At FrOSCon in August we sported not only a project booth but a presentation room as well so we took the
57opportunity to lay on a couple of talks for the delegates.
58
59[[http://wiki.call-cc.org/users/moritz-heidkamp|Moritz Heidkamp]] presented
60"[[http://programm.froscon.org/2011/events/869.html|An introduction to Lisp]]:
61Why to talk to computers in parentheses" whilst
62[[http://wiki.call-cc.org/users/christian-kellermann|Christian Kellermann]] offered
63"[[http://programm.froscon.org/2011/events/867.html|A guided tour through the republic of CHICKEN]]:
64get up to speed with the practical scheme implementation".
65[[http://wiki.call-cc.org/users/christian-kellermann|Christian]] has been keeping his talk up-to-date and
66you can find the latest version [[http://wiki.call-cc.org/chickenista-guide|on the wiki]].
67
68Naturally, there are [[http://www.call-cc.org/pictures/froscon2011/|pictures]].
69
70
71=== T-DOSE 2011 (November 2011)
72European Chickens met up at T-DOSE in Eindhoven, The Netherlands on the weekend of the 5th, 6th and 7th of
73November. [[http://wiki.call-cc.org/users/peter-bex|Peter Bex]] arranged for us to contribute a "Chicken
74Scheme Project Booth" and we subsequently lured a few Dutch hackers into #chicken on IRC.
75
76[[http://wiki.call-cc.org/users/christian-kellermann|Christian Kellermann]] knocked up some impressive demos
77of [[http://en.wikipedia.org/wiki/Pong|PONG]] using Chicken's [[http://wiki.call-cc.org/eggref/4/cairo|Cairo Egg]].
78
79[[http://wiki.call-cc.org/users/alaric-blagrave-snellpym|Alaric Snell-Pym]] finished off the tests for his
80[[http://wiki.call-cc.org/eggref/4/ugarit|Ugarit]] backup egg which allowed him to release version 1.0.
81
82...and [[http://wiki.call-cc.org/users/moritz-heidkamp|Moritz Heidkamp]] started on a replacement for the
83[[http://wiki.call-cc.org/eggref/4/environments|Environments Egg]] as it has unfortunately has been overtaken
84by developments in the Chicken development branch.
85
86Pictures are up in the [[http://www.call-cc.org/pictures/t-dose2011/|usual place]] on the Chicken website.
87
88
89
90== 2. Chicken Talk
91
92=== R7RS to be dedicated to the memory of John McCarthy
93
94Matt Welland wrote in with the sad news that the "Father of Lisp", John McCarthy had sadly passed away ([[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00115.html|2011/10/25 15:59Z]]). [[http://wiki.call-cc.org/users/john-cowan|John Cowan]], member of the R7RS working group, told us that R7RS,
95the upcoming version of the Scheme standard, would be dedicated to his memory ([[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00116.html|16:22Z]])
96
97
98=== Parallel build patch for Chicken Makefile
99
100A lively discussion broke out on the [[https://wiki.call-cc.org/mailing-lists|Chicken Users mailing list]] regarding
101[[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00025.html|parallelisation of the Chicken build process]].
102
103Vitaly Magerya supplied a [[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00025.html|patch]] (2011/10/06 12:37Z) to fix some problems
104he'd been having with builds failing when specifying the {{-j}} to {{gmake}}.
105[[http://wiki.call-cc.org/users/mario-domenech-goulart|Mario Domenech Goulart]] noted that this functionality was already being
106addressed by [[http://bugs.call-cc.org/ticket/526|ticket 526]]
107([[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00027.html|2011/10/06 12:39Z]]) and Vitaly was keen to see it committed
108soonly as he maintains the FreeBSD port and people had been asking him for parallel builds ([[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00028.html|2011/10/06 14:24Z]]). Whilst still keen, [[http://wiki.call-cc.org/users/mario-domenech-goulart|Mario]] [[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00029.html|advised caution]] as he wanted to see it proven ([[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00031.html|2011/10/06 14:40Z]]).
109
110Vitaly was keen to push things forward ([[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00033.html|2011/10/06 15:45Z]]) and
111offered continued testing under FreeBSD 8.2-RELEASE on x86_64. He noted that, as far as he could tell, {{gmake check}} passed when using his
112patch, modified with [[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00026.html|Moritz Wilhelmy's suggestions]]. Moreover, he
113offered to try the patch from [[http://bugs.call-cc.org/ticket/526|ticket 526]] as well.
114
115[[http://wiki.call-cc.org/users/mario-domenech-goulart|Mario]] [[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00034.html|suggested]]
116that using the [[http://bugs.call-cc.org/ticket/526|ticket 526]] patch was a good idea as it had, as far as he knew, received testing under Linux and MacOSX.
117
118Toby Thain spoke in favour of the patch, saying that a working parallel build gives confidence that the Makefile is, in fact, correct.
119He offered to test on three platforms, namely Solaris 10 SPARC SMP and both PowerPC and Intel version of MacOSX SMP.
120
121Vitaly updated the [[http://bugs.call-cc.org/ticket/526|ticket 526]] patch to the then current sources and confirmed that the build worked at {{-j8}}
122and the tests passed in his FreeBSD 8.2-RELEASE, x86_64 environment. He did, however, note that parallelisation does not work for the install phase
123([[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00048.html|2011/10/08 12:29Z]]).
124
125Toby Thain reported successful builds on the 64-bit version MacOSX-10.6 as well as MacOSX-10.5 on a dual-processor G5. He noted "{{make -j8}}
126reduces the make step from 3:39 to 0:47 on my 8-core system". Unfortunately {{make check}} did not pass on either system, with or without the patch
127([[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00071.html|2011/10/12 01:59Z]] &
128[[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00100.html|2011/10/15 19:53Z]])
129
130[[http://wiki.call-cc.org/users/christian-kellermann|Christian Kellermann]] noted that it might necessary to install the compiled binaries
131([[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00101.html|2011/10/15 20:07Z]]) however, Toby did not report back as to whether this
132had any effect on the results of the tests.
133
134
135=== 64-bit SPARC Build
136
137Nicolas Pelletier came to the [[https://wiki.call-cc.org/mailing-lists|mailing list]]
138unable to build for Solaris 10 running on SPARC64 due to a missing {{apply-hack.S}}
139([[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00012.html|2011/11/09 11:48Z]]).
140
141It turned out that there was no SPARC64 support for Chicken at all and [[http://wiki.call-cc.org/users/john-cowan|John Cowan]]
142came to the rescue ([[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00013.html|15:36Z]])
143with instructions for how to add it to the supported architectures list and disable the
144apply hack. [[http://wiki.call-cc.org/users/christian-kellermann|Christian Kellermann]] chimed in with affirmations
145around the utility of using Chicken without an apply hack ([[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00014.html|15:54Z]])
146
147Nicolas struggled with disabling the apply hack ([[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00015.html|2011/11/10 11:10Z]])
148due to the Two Lies Of The README. Over the course of the next few minutes [[http://wiki.call-cc.org/users/christian-kellermann|Christian]]
149and [[http://wiki.call-cc.org/users/mario-domenech-goulart|Mario Domenech Goulart]]]
150confirmed that the lies, which related to the way bootstrap compilers are distributed and invoked, had
151already been fixed in the development versions.
152
153Meanwhile, Toby Thain tried the build on his SPARC64 ([[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00020.html|12:40Z]])
154and discovered that GNU make 3.82 is required as well as the addition of {{-lrt}} in {{Makefile.solaris}}. Toby's
155build eventually succeeded and appeared to be good, albeit having only used 1 of his 4 CPUs and with a couple of {{make check}} errors.
156
157Later on the Thursday, [[http://wiki.call-cc.org/users/jim-ursetto|Jim Ursetto]] noted ([[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00021.html|16:47Z]])
158that the [[http://bugs.call-cc.org/raw-attachment/ticket/526/parallel-build-2.diff.txt|parallel build patch]] in
159[[http://bugs.call-cc.org/ticket/526|ticket 526]] still works on Chicken 4.7.0.3-st. Toby [[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00022.html|confirmed]]
160that the patch did indeed work on Solaris and build time was reduced to 10 just of his Earth minutes from the original 40.
161Of course, user time across the four CPUs was still in the region of 40 minutes in total. :-)
162
163To round everything off, Toby offered [[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00028.html|binary SYSV packages for Solaris 10 on SPARC64]].
164Contact him via the [[https://wiki.call-cc.org/mailing-lists|mailing list]] if you're interested.
165
166
167=== Static Linking & Standalone Binaries.
168
169Serg Kozhemyakin [[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00105.html|asked]] whether it is possible to build static
170binaries after having trouble using the {{-static}} flag to {{csc}}. He also wondered about building standalone binaries for Windows.
171[[http://wiki.call-cc.org/users/christian-kellermann|Christian Kellermann]] [[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00106.html|advised]]
172against static linking as many of the eggs cannot cope with it. He did, however, suggest that the {{-deploy}} option may well solve both
173issues as it ensures that all the DLLs (including the Chicken runtime and other shared objects) are bundled together into a single directory.
174
175
176=== Tracing with {{,tr}} moved to an egg
177
178[[http://wiki.call-cc.org/users/mario-domenech-goulart|Mario Domenech Goulart]] [[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00007.html|helped]]
179Curtis Cooley in his [[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00006.html|search for the {{,tr}} command]].
180The functionality had been moved from the core into an egg in Chicken 4.3.0.
181
182
183=== {{gmake check}} sometimes fails.
184
185Pekka Niiranen wrote to tell us about
186[[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00009.html|problems with {{gmake check}} in Chicken 4.7.0-st]]
187on OpenBSD 5.0.
188
189[[http://wiki.call-cc.org/users/jim-ursetto|Jim Ursetto]] [[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00010.html|said]]
190that one of the failures had been fixed in the stability branch after the Chicken 4.7.0-st release and he filed
191[[https://bugs.call-cc.org/ticket/724|ticket 724]] for the segmentation fault issue.
192
193[[http://wiki.call-cc.org/users/peter-bex|Peter Bex]] mentioned that the [[https://bugs.call-cc.org/ticket/724|ticket 724]] segmentation
194fault had also been observed under NetBSD and Arch Linux. He said that "It's known to be broken" but that it is not properly reproducible
195as it only happens some of the time ([[http://lists.nongnu.org/archive/html/chicken-users/2011-11/msg00011.html|2011/11/06 09:51|]]).
196
197
198== 3. Salmonella and other tests
199Salmonella is Chicken's egg testing framework.
200
201For some time we have had daily salmonella runs of the master development
202version of Chicken under Linux on x86. Throughout November, MacOSX-x86_64 has also
203been regularly experiencing the runs. [[http://wiki.call-cc.org/users/mario-domenech-goulart|Mario Domenech Goulart]] who maintains the testing
204effort at [[http://tests.call-cc.org/]], as well as the [[https://github.com/mario-goulart/salmonella|Salmonella codebase]]
205itself, is always on the lookout for more feeds. We are aware that testing on
206other platforms is being organised but if you've got a private Salmonella
207running regularly on an interesting operating system or version of Chicken then
208give us a shout and we'll see if we can get it included with the other reports
209on [[http://tests.call-cc.org/]]
210
211There is also [[https://github.com/mario-goulart/salmonella|an entirely new version of Salmonella]] over at github so test that too. The new version is more modular -- some features that were previously built in salmonella are now independent eggs (e.g., [[https://github.com/mario-goulart/salmonella-html-report|salmonella-html-report]] and [[https://github.com/mario-goulart/salmonella-feeds|salmonella-feeds]].  There's also a new egg that provides a new feature: [[https://github.com/mario-goulart/salmonella-diff|salmonella-diff]] which generates HTML output to render differences between two salmonella logs.
212
213Here's short list of new salmonella features:
214
215* egg lint mode: salmonella can now easily check for common egg mistakes before the code hits the egg repository.  Just run {{salmonella --this-egg}} from the egg directory
216* a new execution mode that can significantly reduce salmonella execution times.  In this mode, salmonella won't set the temporary egg installation directory empty before installing new eggs.  While this mode won't spot egg dependencies problems, it can drastically effect the execution time
217* a new tool to take advantage of multi-core systems ({{salmonella-epidemy}})
218* a simple text mode log file viewer ({{salmonella-log-viewer}})
219* [[https://github.com/mario-goulart/salmonella-html-report|salmonella-html-report]] generates reverse dependencies graphs.  That can be useful, for
220example, to ilustrate how many eggs depend on a given egg.
221
222
223[[http://wiki.call-cc.org/users/alaric-blagrave-snellpym|Alaric Snell-Pym]] is one of the people who has been setting up a Chicken testing
224environment. After [[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00068.html|some discussion]], he chose Chicken 4.5.0 under
225NetBSD ([[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00035.html|2011/10/06 21:18Z]]). He's been keeping track of all the
226Egg dependencies and plans to publish them as a list of NetBSD pkgsrc packages.
227
228Thanks to [[http://www.bevuta.com/|bevuta IT GmbH]], the CHICKEN test
229infrastructure will soon have more machines available to test the
230CHICKEN compiler, tools and eggs.  A new salmonella environment for
231Linux/x86-64 is currently being set up.
232
233In addition to salmonella, work on the
234[[http://wiki.call-cc.org/playground|Chicken Playground]] project has
235been resumed.  The Chicken Playground project provides environments
236that can be used by tools like {{chroot}} to test CHICKEN tools and
237eggs.  Those environments contain tools and libraries required to
238build and test most eggs.  Currently a Linux/x86 environment is
239available. A Linux/x86-64 environment is under development and should
240be available soon.
241
242The new test infrastructure, based on new versions of salmonella and
243Chicken Playground and running on new platforms will probably go into
244production during the Nuremberg hackaton.
245
246
247== 4. Core Development
248
249Since the last issue most core development took place in the
250"scrutinizer", the flow-analysis pass used for determining the number
251and types of values as they propagate through Scheme expressions. The
252results of this analysis is now used to replace various primitive
253operations by more efficient code, taking advantage of the obtained
254type information. Over the last months the typing and rewrite rules of
255all core library procedures (which can be found in the installed
256"types.db" file) have been heavily improved and debugged. Depending on
257the nature of the code, these optimizations can result in significant
258performance improvements. For more information on specialisation see
259the respective section at
260[[http://library.readscheme.org/page10.html|readscheme.org]].
261
262A couple of months ago the CHICKEN team has formalised the development
263process a bit as can be seen on
264[[http://wiki.call-cc.org/development-process|its wiki page]]. Others
265already joined in the discussion of patches on
266[[https://lists.nongnu.org/mailman/listinfo/chicken-hackers|chicken-hackers]]
267and you are more than welcome to join in.
268
269As more people are trying git checkouts, the question of how to
270bootstrap a git checkout properly keeps reappearing on the mailing
271list. So the steps are:
272
273* Build a [[http://code.call-cc.org|stable release]] or a [[http://code.call-cc.org/dev-snapshots|development snapshot]]
274* Checkout chicken-core from git (see [[http://code.call-cc.org]])
275* Build a boot-chicken: {{make boot-chicken}}
276* Use this chicken to build the real chicken: {{make CHICKEN=./chicken-boot}}
277* Install the chicken and run tests: {{make install && make check}}
278
279
280sparc64
281mario, felix
282lots of bug fixes, sparc64 support
283
284 * On origin/master:
285   * (e1a5437): when conditional branches differ in the number of results, do not merge the results (felix, 2 days ago)
286   * (bae7d92): clustering optimization added (felix, 5 weeks ago)
287   * (b1907c5): use different default stack-sizes on 32/64 bit platforms (felix, 6 days ago)
288   * (986bd3f): disable apply-hack on sparc64 (felix, 6 days ago)
289   * (28a36bf): Remove scripts/make-egg-rss-feed.scm (imported into the chicken-infrastructure repo) (Mario Domenech Goulart, 5 days ago)
290   * (fbeffd1): scripts/tools.scm: needs regex for `string-match' (Mario Domenech Goulart, 5 days ago)
291   * (1fca9c6): use equal? in case MSYSTEM is not defined (makedist.scm) (felix, 6 days ago)
292   * (42a8263): don't remove build-info files on make confclean or it is not possible to build from a tarball without preinstalled chicken (felix, 9 days ago)
293   * (3bb9645): write debugging output for optimizations into generated source file (felix, 3 weeks ago)
294   * (e7fe2fb): allow procedure in operator-position of evaluated list (#705, suggested by John Cowan) (felix, 2 weeks ago)
295   * (e2fb31c): fix subtype check for fixed-size list/vector types in scrutinizer (felix, 10 days ago)
296   * (fd018df): strip std-envs of non-std identifiers, ignore ##sys#macro-environment when evaluating with an explicit environment (felix, 13 days ago)
297   * (fe8f63c): minor change in port-tests.scm to handle case when HOME is not defined (Windows) (felix, 2 weeks ago)
298   * (723a469): cut of union types above a certain length (felix, 2 weeks ago)
299   * (919a7c7): fixes in build + Windows test script, added note to README (thanks to mario) (felix, 2 weeks ago)
300   * (ddb96f9): Also added runtests.bat to manifest. (felix, 3 weeks ago)
301   * (0df9bb8): another trivial fix for making boot-chicken work on cmd.exe (felix, 3 weeks ago)
302   * (cea668f): trivial Windows-related corrections in rules.make, found by Mario - not yet working, though (felix, 3 weeks ago)
303   * (1bc311d): undocumented scrutinize declaration (obsolete), reported by ckeen (felix, 3 weeks ago)
304   * (10494f6): fixed stupid paren-matching error (felix, 3 weeks ago)
305   * (f9a6702): disable debug output in scrutinizer (felix, 5 weeks ago)
306   * (2483f8d): check not necessary for lambda and  warn if using keyword as variable in binding form (felix, 3 weeks ago)
307   * (aa6b2bb): cleaning up uninitialized variables in C_reclaim, add debug output to C_mutate on m-stack resize, grow m-stack at higher rate (felix, 3 weeks ago)
308   * (1e04156): use write-string port-class method (felix, 3 weeks ago)
309   * (59cdaaf): remove obsolete C_h_... allocation functions (pointed out by Joerg Wittenberger) (felix, 3 weeks ago)
310   * (159611d): handle macro-aliases when resolving declared identifier, making sure things are done right inside modules. (felix, 4 weeks ago)
311   * (0cc88a4): removed obsolete file (felix, 4 weeks ago)
312   * (1f56f3a): ##core#type makes subtype-check optional; quit compile when type-mismatches in strict mode (felix, 5 weeks ago)
313
314
315== 5. Stability is for Chickens
316
317[[http://wiki.call-cc.org/users/jim-ursetto|Jim Ursetto]] has set up a Chicken Stability Branch
318effort over at [[http://wiki.call-cc.org/stability]]. Jim describes it as "a fork of the Chicken
319Scheme core which backports certain useful bugfixes and minor features from the future to 'stable'
320maintenance versions". Releases for stability/4.7.0 have version numbers like {{4.7.0.x-st}} (for
321example, {{4.7.0.1-st}}). If you're interested in running a stable Chicken in production, we recommend
322that you check out Jim's work.
323
324
325
326== 6. Hatching Farm
327
328There has been a lot of egg activity over the course of the past few months. I've selected a few,
329focussing on ones that were announced or discussed on the [[https://wiki.call-cc.org/mailing-lists|mailing list]].
330
331TODO: Write about the distributed egg repository
332
333By far the most notable thing to have happened is the announcment and implementation of the new
334Egg management system.
335
336* [[http://wiki.call-cc.org/users/ivan-raikov|Ivan Raikov]]'s [[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00058.html|proposal]]
337  to recategorise eggs filed under "Uncategorized or invalid" and "Miscellaneous" was met with enthusiasm with a number of people pitching in to
338  help as well as [[http://wiki.call-cc.org/users/peter-bex|Peter Bex]] suggesting that the category list be revisited
339  ([[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00064.html|2011/10/11 08:12Z]]). [[http://wiki.call-cc.org/users/peter-bex|Peter]]
340  specifically suggested the addition of a "Communication"s category.
341
342* [[http://wiki.call-cc.org/users/thomas-chust|Thomas Chust]] announced some new eggs: [[http://www.chust.org/fossils/webkit|bindings to WebKitGTK+ and JavaScriptCore]], [[http://www.chust.org/fossils/webgate|webgate: a tiny (S)CGI application framework]] and a [[http://www.chust.org/fossils/berkeley-db|small binding for the BerkelyDB library]]
343
344* [[http://wiki.call-cc.org/users/christian-kellermann|Christian Kellermann]]
345  [[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00103.html|fixed some bugs]] in the
346  [[http://wiki.call-cc.org/eggref/4/cairo|Cairo Egg]] and tagged version 0.1.11.
347
348* [[http://wiki.call-cc.org/users/alyn.post|Alan Post]] [[http://lists.nongnu.org/archive/html/chicken-users/2011-10/msg00001.html|patched]] the
349  [[http://wiki.call-cc.org/eggref/4/sandbox|Sandbox Egg]] to bring it up-to-date with API changes in the Chicken core. His patch was duly accepted.
350 
351* [[user:moritz-heidkamp|Moritz Heidkamp]] released the [[egg:stemmer|stemmer]] egg which provides bindings for the [[http://snowball.tartarus.org/|Snowball project's]] libstemmer.
352
353
354
355== 7. Donations
356
357It's now possible to donate to your favourite scheme (as long as it's Chicken)!
358
359[[http://wiki.call-cc.org/donate]]
360
361We've already had two donations since the account opened a month ago so get donating before it fills up! :-)
362
363Thank you [[http://wiki.call-cc.org/users/sven-hartrumpf|Sven Hartrumpf]] and Ross Lonstein!
364
365
366== 8. Omelette Recipes
367
368This issue's omelette is the second installment of
369[[http://wiki.call-cc.org/users/alaric-blagrave-snellpym|Alaric Snell-Pym]]'s
370"financial book-keeping in scheme" series. If you missed the first part,
371check it out [[http://gazette.call-cc.org/issues/20.html#omelette-recipes|here]].
372
373Now, to make things easy, I parse the ledger by just defining a heap
374of procedures and macros, and then diving into the ledger with
375eval. It's just Scheme code that, as it is executed, builds up the
376data structures. We'll need some helpers to set up third parties
377properly:
378
379<enscript>
380(define (define-third-party name address group)
381  (let* ((balance-account
382          (make-account
383           (string-append name ".balance")
384           'balance
385           group
386           #f))
387         (expenses-account
388          (make-account
389           (string-append name ".expenses")
390           'delta
391           'expenses-reclaimed
392           #f))
393         (third-party
394          (make-third-party
395           name address balance-account expenses-account)))
396    (account-third-party-set! balance-account third-party)
397    (account-third-party-set! expenses-account third-party)
398    (register-account! balance-account)
399    (register-account! expenses-account)
400    (set! (hash-table-ref *third-parties* name) third-party)))
401</enscript>
402
403Now we can work on a way of representing bills and invoices. A nice
404input syntax would be:
405
406<enscript>
407(define-third-party "clients.widgetcorp" "123 Any Street" 'clients)
408(register-account! (make-account "income.work" 'delta 'income #f))
409(register-account! (make-account "expenses.travel" 'delta 'travel #f))
410(register-account! (make-account "stock.balance" 'balance 'stock #f))
411(register-account! (make-account "cash" 'balance 'cash #f))
412(register-account! (make-account "taxes.vat" 'balance 'vat #f))
413
414(invoice "INV005" "clients.widgetcorp" (ymd 2011 04 25)
415         (service "income.work" 800 (vat20) "Router setup and installation")
416         (sale "stock.balance" 350 (vat20) "1 of LX300 router, serial number 0343248")
417         (expense (ymd 2011 03 02) "expenses.travel" "cash" 35 () "Travel to site"))
418</enscript>
419
420The idea is that the sales taxes incurred on a line are specified as a
421list after the amount. If there's no taxes due, then we use an empty
422list. Otherwise we have a list of taxes, which are either plain tax
423names (to have the system compute the tax due itself) or two-element
424lists joining a tax name to a precomputed amount (often, when we pass
425on an expense, we know the tax we paid as it's on the receipt, so we
426should use that (even if they made a mistake working it out) rather
427than calculating our own).
428
429A nice way to implement that might be to make "invoice" a macro that
430absorbs its first three arguments as an invoice code, the name of the
431third party to invoice, and the date; then treats the rest as a body
432to be wrapped in a dynamic environment in which a parameter allows
433{{sale}}, {{expense}}, and {{service}} to add lines to the
434invoice. This is easily arranged:
435
436<enscript>
437(define-record date year month day)
438
439(define-record invoice
440  name date third-party lines)
441
442(define (register-line! invoice line)
443  (invoice-lines-set! invoice
444                      (cons line (invoice-lines invoice))))
445
446;; Compute sales taxes
447(define (compute-tax tax amount)
448  (case tax
449    ((vat20) (* 0.20 amount)) ;; Current UK rate
450    ((vat15) (* 0.15 amount)) ;; Previous UK rate
451    ((vat175) (* 0.175 amount)))) ;; Previous UK rate
452
453;; Expand a list of taxes, some of which might be bare symbols
454;; naming taxes to work out, or (<tax> <amount>) lists for
455;; ready-computed taxes, into an alist of tax names to tax amounts
456(define (resolve-taxes amount taxes)
457  (map (lambda (tax-desc)
458         (if (list? tax-desc)
459             (cons (car tax-desc) (cadr tax-desc))
460             (cons tax-desc (compute-tax tax-desc amount))))
461       taxes))
462
463(define-record invoice-service-line
464  income-account amount taxes description)
465
466(define-syntax service
467  (syntax-rules ()
468    ((service income-account amount taxes description)
469     (register-service! (*current-invoice*) income-account amount 'taxes description))))
470
471(define (register-service! invoice income-account amount taxes description)
472  (let ((service
473         (make-invoice-service-line
474          (find-account income-account)
475          amount
476          (resolve-taxes amount taxes)
477          description)))
478    (register-line! invoice service)))
479
480(define-record invoice-sale-line
481  stock-account amount taxes description)
482
483(define (register-sale! invoice stock-account amount taxes description)
484  (let ((sale
485         (make-invoice-sale-line
486          (find-account stock-account)
487          amount
488          (resolve-taxes amount taxes)
489          description)))
490    (register-line! invoice sale)))
491
492(define-syntax sale
493  (syntax-rules ()
494    ((sale stock-account amount taxes description)
495     (register-sale! (*current-invoice*) stock-account amount 'taxes description))))
496
497(define-record invoice-expense-line
498  expense-account payment-account amount taxes description)
499
500(define (register-expense! invoice date expense-account payment-account amount taxes description)
501  (let ((expense
502         (make-invoice-expense-line
503          (find-account expense-account)
504          (find-account payment-account)
505          amount
506          (resolve-taxes amount taxes)
507          description)))
508    (register-line! invoice expense)))
509
510(define-syntax expense
511  (syntax-rules ()
512    ((expense (ymd year month day) expense-account payment-account amount taxes description)
513     (register-expense!
514      (*current-invoice*)
515      (make-date year month day)
516      expense-account
517      payment-account
518      amount
519      'taxes
520      description))))
521
522(define *current-invoice* (make-parameter #f))
523(define *invoices* (make-hash-table))
524
525(define-syntax invoice
526  (syntax-rules (service sale expense)
527    ((invoice name third-party (ymd year month day) body ...)
528     (let ((inv
529            (make-invoice name
530                          (make-date year month day)
531                          (hash-table-ref *third-parties* third-party)
532                          '())))
533       (parameterize
534        ((*current-invoice* inv))
535        (begin body ...))
536       (set! (hash-table-ref *invoices* name) inv)
537       (generate-invoice-transactions! inv)))))
538</enscript>
539
540We end the expansion of the {{invoice}} macro with a call to
541{{generate-invoice-transactions!}}, which will do the task of creating
542the double-entry transactions for the invoice. Other types of summary
543structure can be added by calling additional generator procedures at
544this point. This is largely a matter of going through the invoice
545lines, handling them on a case-by-case basis to generate lists of
546transaction splits that we can append together to generate the invoice
547transaction. The case of expense lines is interesting, in that an
548extra transaction has to be generated for each expense, to record its
549initial spending, as well as a split to record the expense being
550claimed in the invoice.
551
552For now, let's just handle one case:
553
554<enscript>
555(define (generate-invoice-transactions! inv)
556  (register-txn! (make-txn
557    (invoice-date inv)
558    (string-append "Invoice " (invoice-name inv) " for "
559                   (third-party-full-name (invoice-third-party inv)))
560    (let ((txn-balance-account
561           (third-party-balance-account
562            (invoice-third-party inv))))
563      (flatten
564       (map
565        (lambda (line)
566          (cond
567           ((invoice-expense-line? line)
568            (list)) ;; FIXME: Not implemented
569           ((invoice-sale-line? line)
570            (list)) ;; FIXME: Not implemented
571           ((invoice-service-line? line)
572            (list
573             (make-txn-split
574              (invoice-service-line-income-account line)
575              (- (invoice-service-line-amount line))
576              (invoice-service-line-description line))
577             (make-tax-splits
578              (invoice-service-line-taxes line)
579              txn-balance-account)
580             (make-txn-split
581              txn-balance-account
582              (invoice-service-line-amount line)
583              #f)))))
584        (invoice-lines inv)))))))
585
586(define (make-tax-splits taxes txn-balance-account)
587  (map (lambda (tax)
588         (let ((tax-type (car tax))
589               (tax-amount (cdr tax)))
590           (case tax-type
591             ((vat20 vat15 vat175)
592              (list
593               (make-txn-split
594                (find-account "taxes.vat")
595                (- tax-amount)
596                #f)
597               (make-txn-split
598                txn-balance-account
599                tax-amount
600                #f))))))
601       taxes))
602</enscript>
603
604Feeding in the above example invoice, then checking out the resulting
605double-entry transaction list, shows that it worked:
606
607<enscript>
608(hash-table-for-each *txns*
609                     (lambda (date txns)
610                       (for-each
611                        (lambda (txn)
612                          (printf "Date: ~A Desc: ~A\n"
613                                  (txn-date txn)
614                                  (txn-description txn))
615                          (for-each (lambda (split)
616                                      (printf "Acct: ~A Delta: ~A Notes: ~A\n"
617                                              (account-name (txn-split-account split))
618                                              (txn-split-amount split)
619                                              (txn-split-notes split))) (txn-splits txn)))
620                        txns)))
621</enscript>
622
623   date: #<date> Desc: Invoice INV005 for Widget Corp
624   Acct: income.work Delta: -800 Notes: Router setup and installation
625   Acct: taxes.vat Delta: -160.0 Notes: #f
626   Acct: clients.widgetcorp.balance Delta: 160.0 Notes: #f
627   Acct: clients.widgetcorp.balance Delta: 800 Notes: #f
628
629We've ended up with multiple splits for the same account, as we record
630that both VAT and the money due for the service are to come from the
631client's balance account - and other splits will add plenty more. To
632fix this, we need to write a procedure that canonicalises a list of
633splits, and call that on the splits before calling
634{{make-txn}}. Canonicalisation consists of finding all the splits that
635refer to the same account and have the same notes (be it {{#f}} or a
636string) and merging them into one with the total of the amounts. But
637I'll leave that (along with implementing bills, payments, and some
638actual reports) as an exercise to the reader... It's easy to imagine
639how to generate a VAT report from the list of transactions, by
640filtering them for membership of the required date range and looking
641for splits involving "taxes.vat", or to generate a nicely formatted
642invoice by extracting a single invoice record, or to work out the
643balance of an account at any point in time by adding up all the
644transaction splits that involve it up to that point in time. Also, the
645core engine needs to be wrapped up in a module that only exposes the
646required bindings, and hides internals.
647
648Having automated one's book-keeping and financial reporting, many
649operations (such as the VAT returns) can be done without involving an
650accountant; in my case, the accountant is only needed to help with the
651annual corporation tax computation and filing of official accounts,
652which requires deep understanding of the UK tax system to do
653everything properly. Having said that, if I studied the system
654properly (and tracked the changes each year), I'm sure I could
655automate that, too...
656
657== 9. About the Chicken Gazette
658
659The Gazette is produced occasionally by a volunteer from the Chicken
660community. The latest issue can be found at
661[[http://gazette.call-cc.org]] or you can follow it in your feed
662reader at [[http://gazette.call-cc.org/feed.atom]]. If you'd like to
663write an issue, [[http://wiki.call-cc.org/gazette|consult the wiki]]
664for the schedule and instructions!
Note: See TracBrowser for help on using the repository browser.