Enclose `regexp.test' in a module.
[bpt/guile.git] / HACKING
CommitLineData
a84251b0
LC
1-*-text-*-
2Guile Hacking Guide
b226295a 3Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2008 Free software Foundation, Inc.
a84251b0
LC
4
5 Permission is granted to anyone to make or distribute verbatim copies
6 of this document as received, in any medium, provided that the
7 copyright notice and permission notice are preserved,
8 and that the distributor grants the recipient permission
9 for further redistribution as permitted by this notice.
10
11 Permission is granted to distribute modified versions
12 of this document, or of portions of it,
13 under the above conditions, provided also that they
14 carry prominent notices stating who last changed them,
15 and that any new or changed statements about the activities
16 of the Free Software Foundation are approved by the Foundation.
17
18
19What to Hack =========================================================
20
21You can hack whatever you want, thank GNU.
22
23However, to see what others have indicated as their interest (and avoid
24potential wasteful duplication of effort), see file TODO. Note that
25the version you find may be out of date; a CVS checkout is recommended:
26see below for details (see also the files ANON-CVS and SNAPSHOTS).
27
28It's also a good idea to join the guile-devel@gnu.org mailing list.
29See http://www.gnu.org/software/guile/mail/mail.html for more info.
30
31
32Hacking It Yourself ==================================================
33
b48efb55 34When Guile is obtained from Git, a few extra steps must be taken
a84251b0 35before the usual configure, make, make install. You will need to have
b48efb55 36up-to-date versions of the tools as listed below, correctly installed.
a84251b0 37
b48efb55
HWN
38Sometimes older or newer versions will work. (See below for versions
39to avoid.)
a84251b0
LC
40
41Then you must run the autogen.sh script, as described below.
42
a84251b0
LC
43The same procedure can be used to regenerate the files in released
44versions of Guile. In that case the headers of the original generated
45files (e.g., configure, Makefile.in, ltmain.sh) can be used to
46identify which tool versions may be required.
47
48Autoconf --- a system for automatically generating `configure'
49 scripts from templates which list the non-portable features a
50 program would like to use. Available in
51 "ftp://ftp.gnu.org/pub/gnu/autoconf"
52
53Automake --- a system for automatically generating Makefiles that
54 conform to the (rather Byzantine) GNU coding standards. The
55 nice thing is that it takes care of hairy targets like 'make
56 dist' and 'make distclean', and automatically generates
57 Makefile dependencies. Automake is available in
58 "ftp://ftp.gnu.org/pub/gnu/automake"
59
60libtool --- a system for managing the zillion hairy options needed
61 on various systems to produce shared libraries. Available in
d4a00708
NJ
62 "ftp://ftp.gnu.org/pub/gnu/libtool". Version 1.5.26 (or
63 later) is needed for correct AIX support.
a84251b0
LC
64
65gettext --- a system for rigging a program so that it can output its
66 messages in the local tongue. Guile presently only exports
67 the gettext functionality to Scheme, it does not use it
68 itself.
69
70flex --- a scanner generator. It's probably not essential to have the
71 latest version.
72
73One false move and you will be lost in a little maze of automatically
74generated files, all different.
75
76Here is the authoritative list of tool/version/platform tuples that
77have been known to cause problems, and a short description of the problem.
78
79- automake 1.4 adds extraneous rules to the top-level Makefile if
80 you specify specific Makefiles to rebuild on the command line.
81
82- automake 1.4-p4 (debian "1:1.4-p4-1.1") all platforms
83 automake "include" facility does not recognize filenames w/ "-".
84
85- libtool 1.4 uses acconfig.h, which is deprecated by newest autoconf
86 (which constructs the equivalent through 3rd arg of AC_DEFINE forms).
87
88- autoreconf from autoconf prior to 2.59 will run gettextize, which
89 will mess up the Guile tree.
90
91- (add here.)
92
93
94Sample GDB Initialization File=========================================
95
96Here is a sample .gdbinit posted by Bill Schottstaedt (modified to
97use `set' instead of `call' in some places):
98
99 define gp
100 set gdb_print($arg0)
101 print gdb_output
102 end
103 document gp
104 Executes (object->string arg)
105 end
106
107 define ge
108 call gdb_read($arg0)
109 call gdb_eval(gdb_result)
110 set gdb_print(gdb_result)
111 print gdb_output
112 end
113 document ge
114 Executes (print (eval (read arg))): ge "(+ 1 2)" => 3
115 end
116
117 define gh
118 call g_help(scm_str2symbol($arg0), 20)
119 set gdb_print($1)
120 print gdb_output
121 end
122 document gh
123 Prints help string for arg: gh "enved-target"
124 end
125
126Bill further writes:
127
128 so in gdb if you see something useless like:
129
130 #32 0x081ae8f4 in scm_primitive_load (filename=1112137128) at load.c:129
131
132 You can get the file name with gp:
133
134 (gdb) gp 1112137128
135 $1 = 0x40853fac "\"/home/bil/test/share/guile/1.5.0/ice-9/session.scm\""
136
137
138Contributing Your Changes ============================================
139
140- If you have put together a change that meets the coding standards
b48efb55
HWN
141described below, we encourage you to submit it to Guile. Post your
142patch to guile-devel@gnu.org.
143
144- We prefer patches generated using 'git format-patch'.
145
146- Provide a description in the commit message, like so:
a84251b0 147
b48efb55
HWN
148 1-line description of change
149
150 More extensive discussion of your change. Document why you are
151 changing things.
152
153 * filename (function name): file specific change comments.
a84251b0
LC
154
155- For proper credit, also make sure you update the AUTHORS file
156(for new files for which you've assigned copyright to the FSF), or
157the THANKS file (for everything else).
158
a84251b0 159
a84251b0
LC
160Coding standards =====================================================
161
a84251b0
LC
162- As for any part of Project GNU, changes to Guile should follow the
163GNU coding standards. The standards are available via anonymous FTP
164from prep.ai.mit.edu, as /pub/gnu/standards/standards.texi and
165make-stds.texi.
166
167- The Guile tree should compile without warnings under the following
168GCC switches, which are the default in the current configure script:
169
170 -O2 -Wall -Wpointer-arith -Wmissing-prototypes
171
172To make sure of this, you can use the --enable-error-on-warning option
173to configure. This option will make GCC fail if it hits a warning.
174
175Note that the warnings generated vary from one version of GCC to the
176next, and from one architecture to the next (apparently). To provide
177a concrete common standard, Guile should compile without warnings from
178GCC 2.7.2.3 in a Red Hat 5.2 i386 Linux machine. Furthermore, each
179developer should pursue any additional warnings noted by on their
180compiler. This means that people using more stringent compilers will
181have more work to do, and assures that everyone won't switch to the
182most lenient compiler they can find. :)
183
a84251b0
LC
184- If you add code which uses functions or other features that are not
185entirely portable, please make sure the rest of Guile will still
186function properly on systems where they are missing. This usually
187entails adding a test to configure.in, and then adding #ifdefs to your
188code to disable it if the system's features are missing.
189
190- The normal way of removing a function, macro or variable is to mark
191it as "deprecated", keep it for a while, and remove it in a later
192release. If a function or macro is marked as "deprecated" it
193indicates that people shouldn't use it in new programs, and should try
194to remove it in old. Make sure that an alternative exists unless it
195is our purpose to remove functionality. Don't deprecate definitions
196if it is unclear when they will be removed. (This is to ensure that a
197valid way of implementing some functionality always exists.)
198
199When deprecating a definition, always follow this procedure:
200
2011. Mark the definition using
202
203 #if (SCM_DEBUG_DEPRECATED == 0)
204 ...
205 #endif
206
207 or, for Scheme code, wrap it using
208
209 (begin-deprecated
210 ...)
211
2122. Make the deprecated code issue a warning when it is used, by using
213 scm_c_issue_deprecation_warning (in C) or issue-deprecation-warning
214 (in Scheme).
215
2163. Write a comment at the definition explaining how a programmer can
217 manage without the deprecated definition.
218
2194. Add an entry that the definition has been deprecated in NEWS and
220 explain what do do instead.
221
2225. In file TODO, there is a list of releases with reminders about what
223 to do at each release. Add a reminder about the removal of the
224 deprecated defintion at the appropriate release.
225
b48efb55
HWN
226- Write commit messages for functions written in C using the
227functions' C names, and write entries for functions written in Scheme
228using the functions' Scheme names. For example,
a84251b0 229
b48efb55 230 * foo.c: Moved scm_procedure_documentation from eval.c.
a84251b0 231
b48efb55 232is preferred over
a84251b0 233
b48efb55 234 * foo.c: Moved procedure-documentation from eval.c.
a84251b0
LC
235
236Changes like adding this line are special:
237
238 SCM_PROC (s_map_in_order, "map-in-order", 2, 0, 1, scm_map);
239
240Since the change here is about the name itself --- we're adding a new
241alias for scm_map that guarantees the order in which we process list
242elements, but we're not changing scm_map at all --- it's appropriate
b48efb55 243to use the Scheme name in the commit message.
a84251b0
LC
244
245- Make sure you have papers from people before integrating their
246changes or contributions. This is very frustrating, but very
247important to do right. From maintain.texi, "Information for
248Maintainers of GNU Software":
249
250 When incorporating changes from other people, make sure to follow the
251 correct procedures. Doing this ensures that the FSF has the legal
252 right to distribute and defend GNU software.
253
254 For the sake of registering the copyright on later versions ofthe
255 software you need to keep track of each person who makes significant
256 changes. A change of ten lines or so, or a few such changes, in a
257 large program is not significant.
258
259 *Before* incorporating significant changes, make sure that the person
260 has signed copyright papers, and that the Free Software Foundation has
261 received them.
262
263If you receive contributions you want to use from someone, let me know
264and I'll take care of the administrivia. Put the contributions aside
265until we have the necessary papers.
266
267Once you accept a contribution, be sure to keep the files AUTHORS and
268THANKS uptodate.
269
270- When you make substantial changes to a file, add the current year to
271the list of years in the copyright notice at the top of the file.
272
273- When you get bug reports or patches from people, be sure to list
274them in THANKS.
275
276
277Naming conventions =================================================
278
279We use certain naming conventions to structure the considerable number
280of global identifiers. All identifiers should be either all lower
281case or all upper case. Syllables are separated by underscores `_'.
282All non-static identifiers should start with scm_ or SCM_. Then might
283follow zero or more syllables giving the category of the identifier.
284The currently used category identifiers are
285
286 t - type name
287
288 c,C - something with a interface suited for C use. This is used
289 to name functions that behave like Scheme primitives but
290 have a more C friendly calling convention.
291
292 i,I - internal to libguile. It is global, but not considered part
293 of the libguile API.
294
295 f - a SCM variable pointing to a Scheme function object.
296
297 F - a bit mask for a flag.
298
299 m - a macro transformer procedure
300
301 n,N - a count of something
302
303 s - a constant C string
304
305 k - a SCM variable pointing to a keyword.
306
307 sym - a SCM variable pointing to a symbol.
308
309 var - a SCM variable pointing to a variable object.
310
311The follwing syllables also have a technical meaning:
312
313 str - this denotes a zero terminated C string
314
315 mem - a C string with an explicit count
316
317
318See also the file `devel/names.text'.
319
320
321Helpful hints ========================================================
322
323- [From Mikael Djurfeldt] When working on the Guile internals, it is
324quite often practical to implement a scheme-level procedure which
325helps you examine the feature you're working on.
326
327Examples of such procedures are: pt-size, debug-hand and
328current-pstate.
329
330I've now put #ifdef GUILE_DEBUG around all such procedures, so that
331they are not compiled into the "normal" Guile library. Please do the
332same when you add new procedures/C functions for debugging purpose.
333
334You can define the GUILE_DEBUG flag by passing --enable-guile-debug to
335the configure script.
336
a84251b0
LC
337
338Jim Blandy, and others
339