source: project/gazette/src/issues/16.wiki @ 21990

Last change on this file since 21990 was 21990, checked in by Moritz Heidkamp, 9 years ago

gazette #16: modules omelette (RAW)

File size: 6.5 KB
Line 
1((title . "Issue 16")
2 (authors "Christian Kellermann")
3 (date . 1292230155))
4
5== 0. Introduction
6
7Welcome to issue 16 of the Chicken Gazette.
8
9== 1. The Hatching Farm
10
11It has been a bit quiet in the egg repository apart from
12[[user:kon-lovett|Kon Lovett]] releasing a new version of the
13[[egg:lookup-table|lookup-table egg]].  [[user:alyn.post|Alan Post]]
14has been busy getting his [[egg:genturfahi|genturfa'i egg]] into
15shape. [[user:mario-domenech-goulart|Mario Goulart]] has ported the
16[[egg:statvfs|statvfs egg]] to chicken 4.
17
18== 2. Core development
19
20In the {{experimental}} branch of the [[http://code.call-cc.org|code
21repository]] several bugs have been fixed this week:
22
23* [[ticket:438|Ticket #438]]: Makefile's clean target removed generated setup-api
24  DISTFILEs which is not acceptable.
25
26* [[ticket"340|Ticket #340]]: (Spiffy hangs occasionally (again!)) has been closed
27  since it seems that the fixes introduced in the {{safer-scheduler}}
28  branch are fixing (or hiding) the problem. Additionally Peter fixed
29  a couple of bugs in the openssl bindings.
30
31* [[ticket:424|Ticket #424]]: (umask support) our first change request has been accepted!
32
33* [[ticket:447|Ticket #447]]: Inconsistencies when calling set-finalizer! multiple
34  times have been found by [[user:moritz-heidkamp|Moritz Heidkamp]]
35  and fixed by [[user:felix-winkelmann|Felix Winkelmann]]. Finalizers
36  are scanned first and then marked to make sure the first mark will
37  trigger the finalizer of the object.
38
39* [[ticket:444|Ticket #444]]: Symbol lookup fails in modules in conjunction with
40  renaming macros: [[user:peter-bex|Peter Bex]] came up with a patch
41  to fix this bug which turned out to be of a more general nature than
42  just affecting the IR-macro expander.
43
44Also chicken now has another scrutinizer mode called
45{{-picky}}. ''When given, the scrutinizer warns about undefined
46branches in conditionals in tail-position of global procedures that do
47not perform a self-call.'' as Felix explains on
48[[http://www.mail-archive.com/chicken-users@nongnu.org/msg12765.html|chicken-users]]
49
50The debug switch ''-:d'' is now also handed to the ''chicken'' program
51by the compiler driver ''csc''.
52
53And we welcome back our lambda lifting code which has been put back
54into the experimental branch by Felix.
55
56== 3. Chicken Talk
57
58But alas, this has also been bug finding week! [[user:alyn.post|Alan
59Post]] as well as Moritz and Peter stumbled over some strange findings
60during the last week. Alan's [[egg:genturfahi|genturfa'i]] egg somehow
61caused the compiler to create huge amounts of code as you know from
62[[issues/15.html|last week's]] issue.
63
64The reason for this has been determined: Procedures have been
65[[http://www.mail-archive.com/chicken-users@nongnu.org/msg12731.html|compared
66with equal?]] which had possible circular structure. If you are
67interested in the process of this issue follow
68[[ticket:440|ticket #440]].
69
70[[user:sven-hartrumpf|Sven Hartrumpf]] pointed out a problem in the
71handling of a huge number of
72[[http://www.mail-archive.com/chicken-users@nongnu.org/msg12740.html|command
73line arguments]], which Felix fixed in the {{experimental}} branch.
74
75David Dreisigmeyer has been running into problems with the
76[[egg:bind|bind egg's]]
77[[http://www.mail-archive.com/chicken-users@nongnu.org/msg12761.html|parser]]
78that still have to be resolved.
79
80Apart from other smaller questions to the list we have experienced an
81outtake of the chicken-users mailing list due to the recent hack at
82GNU's savannah site. In the meantime FSF's admin have been able to
83restore the list and its archives to full functionality. Thanks for
84that.
85
86== 4. Omelette Recipes
87
88This week I'd like to give you a brief introduction to
89[[http://wiki.call-cc.org/man/4/Modules|Chicken's module system]]. Modules
90form a ''namespace'' or ''environment''. Basically you can think of
91modules as containers for bindings. Also you have full control over
92which bindings are exported from a module. This way you don't have to
93worry about polluting the global namespace with auxiliary bindings. No
94silly name prefixes anymore! An example illustrates this best:
95
96<enscript language="scheme">
97(module palindrome
98
99  (palindromify palindrome?)
100
101  (import chicken scheme srfi-13)
102
103  (define (palindromify s)
104    (string-append s (string-reverse s)))
105   
106  (define (palindrome? s)
107    (let* ((len (string-length s))
108           (half (quotient len 2)))
109      (if (odd? len)
110          (palindrome? (string-append (string-take s half)
111                                      (string-drop s (+ half 1))))
112          (string=? (string-reverse (string-take s half))
113                    (string-drop s half)))))
114)
115</enscript>
116
117As you can see, it's pretty straight forward. Unsurprisingly, the
118{{module}} form introduces a module definition. The first symbol
119{{palindrome}} is the module's name, followed by a list of symbols to
120be exported from the module: {{(palindromify palindrome?)}}. These
121symbols have to be bound somewhere inside the module. The rest of the
122form is regular Scheme establishing these bindings. The first thing we
123have to do is {{(import chicken scheme srfi-13)}}. Yes, this means a
124module's environment is completely blank initially (except for the
125{{import}} and {{use}} forms) thus we even have to import {{scheme}},
126yet! This is an especially nice way to create an environment for a
127DSL: No regular Scheme bindings are going to get in your way. In our
128case we stick to Chicken flavored Scheme and some SRFI-13 goodness to
129define a few palindrome procedures.
130
131How to use this module now? Well, just import it like any other
132module. Try sticking the above code into a {{palindrome.scm}} file,
133{{load}} it in a {{csi}} REPL and then {{(import palindrome)}}:
134
135 #;1> (load "palindrome.scm")
136 ; loading palindrome.scm ...
137 #;2> (import palindrome)
138 #;3> (palindrome? "chicken")
139 #f
140 #;4> (palindromify "fo")     
141 "foof"
142 #;5> (palindrome? (palindromify "fo"))
143 #t
144
145See, no rocket science in that, though some basic linguistics. The
146best thing is that the modules we imported into our {{palindrome}}
147module are not visible in the environment our module is imported
148into. So if our REPL environment hadn't {{srfi-13}} imported before
149importing our module, it still won't have it afterwards. Nice!
150
151== 5. About the Chicken Gazette
152
153The Gazette is produced weekly by a volunteer from the Chicken
154community. The latest issue can be found at
155[[http://gazette.call-cc.org]] or you can follow it in your feed
156reader at [[http://gazette.call-cc.org/feed.atom]]. If you'd like to
157write an issue, [[http://wiki.call-cc.org/gazette|consult the wiki]]
158for the schedule and instructions!
Note: See TracBrowser for help on using the repository browser.