HACKING 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. -*-text-*-
  2. Guile Hacking Guide
  3. Copyright (c) 1996-2002,2008,2012,2015,2017 Free Software Foundation, Inc.
  4. Permission is granted to anyone to make or distribute verbatim copies
  5. of this document as received, in any medium, provided that the
  6. copyright notice and permission notice are preserved,
  7. and that the distributor grants the recipient permission
  8. for further redistribution as permitted by this notice.
  9. Permission is granted to distribute modified versions
  10. of this document, or of portions of it,
  11. under the above conditions, provided also that they
  12. carry prominent notices stating who last changed them,
  13. and that any new or changed statements about the activities
  14. of the Free Software Foundation are approved by the Foundation.
  15. What to Hack =========================================================
  16. You can hack whatever you want, thank GNU.
  17. It's a good idea to join the guile-devel@gnu.org mailing list. See
  18. http://www.gnu.org/software/guile/mail/mail.html for more info.
  19. Hacking It Yourself ==================================================
  20. When Guile is obtained from Git, a few extra steps must be taken
  21. before the usual configure, make, make install. You will need to have
  22. up-to-date versions of the tools as listed below, correctly installed.
  23. Sometimes older or newer versions will work. (See below for versions
  24. to avoid.)
  25. Then you must run the autogen.sh script, as described below.
  26. The same procedure can be used to regenerate the files in released
  27. versions of Guile. In that case the headers of the original generated
  28. files (e.g., configure, Makefile.in, ltmain.sh) can be used to
  29. identify which tool versions may be required.
  30. Autoconf --- a system for automatically generating `configure'
  31. scripts from templates which list the non-portable features a
  32. program would like to use. Available in
  33. "ftp://ftp.gnu.org/pub/gnu/autoconf"
  34. Automake --- a system for automatically generating Makefiles that
  35. conform to the (rather Byzantine) GNU coding standards. The
  36. nice thing is that it takes care of hairy targets like 'make
  37. dist' and 'make distclean', and automatically generates
  38. Makefile dependencies. Automake is available in
  39. "ftp://ftp.gnu.org/pub/gnu/automake"
  40. libtool --- a system for managing the zillion hairy options needed
  41. on various systems to produce shared libraries. Available in
  42. "ftp://ftp.gnu.org/pub/gnu/libtool". Version 2.2 (or
  43. later) is recommended (for correct AIX support, and correct
  44. interaction with the Gnulib module for using libunistring).
  45. gettext --- a system for rigging a program so that it can output its
  46. messages in the local tongue. Guile presently only exports
  47. the gettext functionality to Scheme, it does not use it
  48. itself.
  49. flex --- a scanner generator. It's probably not essential to have the
  50. latest version; Flex 2.5.37 is known to work.
  51. One false move and you will be lost in a little maze of automatically
  52. generated files, all different.
  53. Here is the authoritative list of tool/version/platform tuples that
  54. have been known to cause problems, and a short description of the problem.
  55. Sample GDB Initialization File=========================================
  56. In GDB, you probably want to load the gdbinit file included with Guile,
  57. which defines a number of GDB helpers to inspect Scheme values.
  58. Contributing Your Changes ============================================
  59. - If you have put together a change that meets the coding standards
  60. described below, we encourage you to submit it to Guile. Post your
  61. patch to guile-devel@gnu.org.
  62. - We prefer patches generated using 'git format-patch'.
  63. - Provide a description in the commit message, like so:
  64. 1-line description of change
  65. More extensive discussion of your change. Document why you are
  66. changing things.
  67. * filename (function name): file specific change comments.
  68. - For proper credit, also make sure you update the AUTHORS file
  69. (for new files for which you've assigned copyright to the FSF), or
  70. the THANKS file (for everything else).
  71. Coding standards =====================================================
  72. - As for any part of Project GNU, changes to Guile should follow the
  73. GNU coding standards. The standards are available via anonymous FTP
  74. from prep.ai.mit.edu, as /pub/gnu/standards/standards.texi and
  75. make-stds.texi.
  76. - The Guile tree should compile without warnings under the following
  77. GCC switches, which are the default in the current configure script:
  78. -O2 -Wall -Wpointer-arith -Wmissing-prototypes
  79. To make sure of this, you can use the --enable-error-on-warning option
  80. to configure. This option will make GCC fail if it hits a warning.
  81. Note that the warnings generated vary from one version of GCC to the
  82. next, and from one architecture to the next. For this reason,
  83. --enable-error-on-warning is not enabled by default.
  84. - If you add code which uses functions or other features that are not
  85. entirely portable, please make sure the rest of Guile will still
  86. function properly on systems where they are missing. This usually
  87. entails adding a test to configure.in, and then adding #ifdefs to your
  88. code to disable it if the system's features are missing. Do check first
  89. if the function has a Gnulib wrapper, though.
  90. - The normal way of removing a function, macro or variable is to mark
  91. it as "deprecated", keep it for a while, and remove it in a later
  92. release. If a function or macro is marked as "deprecated" it
  93. indicates that people shouldn't use it in new programs, and should try
  94. to remove it in old. Make sure that an alternative exists unless it
  95. is our purpose to remove functionality. Don't deprecate definitions
  96. if it is unclear when they will be removed. (This is to ensure that a
  97. valid way of implementing some functionality always exists.)
  98. When deprecating a definition, always follow this procedure:
  99. 1. Mark the definition using
  100. #if (SCM_DEBUG_DEPRECATED == 0)
  101. ...
  102. #endif
  103. or, for Scheme code, wrap it using
  104. (begin-deprecated
  105. ...)
  106. 2. Make the deprecated code issue a warning when it is used, by using
  107. scm_c_issue_deprecation_warning (in C) or issue-deprecation-warning
  108. (in Scheme).
  109. 3. Write a comment at the definition explaining how a programmer can
  110. manage without the deprecated definition.
  111. 4. Add an entry that the definition has been deprecated in NEWS and
  112. explain what to do instead.
  113. - Write commit messages for functions written in C using the
  114. functions' C names, and write entries for functions written in Scheme
  115. using the functions' Scheme names. For example,
  116. * foo.c: Moved scm_procedure_documentation from eval.c.
  117. is preferred over
  118. * foo.c: Moved procedure-documentation from eval.c.
  119. Changes like adding this line are special:
  120. SCM_PROC (s_map_in_order, "map-in-order", 2, 0, 1, scm_map);
  121. Since the change here is about the name itself --- we're adding a new
  122. alias for scm_map that guarantees the order in which we process list
  123. elements, but we're not changing scm_map at all --- it's appropriate
  124. to use the Scheme name in the commit message.
  125. - Make sure you have papers from people before integrating their
  126. changes or contributions. This is very frustrating, but very
  127. important to do right. From maintain.texi, "Information for
  128. Maintainers of GNU Software":
  129. When incorporating changes from other people, make sure to follow the
  130. correct procedures. Doing this ensures that the FSF has the legal
  131. right to distribute and defend GNU software.
  132. For the sake of registering the copyright on later versions ofthe
  133. software you need to keep track of each person who makes significant
  134. changes. A change of ten lines or so, or a few such changes, in a
  135. large program is not significant.
  136. *Before* incorporating significant changes, make sure that the person
  137. has signed copyright papers, and that the Free Software Foundation has
  138. received them.
  139. If you receive contributions you want to use from someone, let a
  140. maintainer know and they will take care of the administrivia. Put the
  141. contributions aside until we have the necessary papers.
  142. Once you accept a contribution, be sure to keep the files AUTHORS and
  143. THANKS up-to-date.
  144. - When you make substantial changes to a file, add the current year to
  145. the list of years in the copyright notice at the top of the file.
  146. - When you get bug reports or patches from people, be sure to list
  147. them in THANKS.
  148. - Do not introduce trailing whitespace (and feel free to clean it up
  149. opportunistically, that is, if doing so is part of some other change).
  150. The goal is to reduce (and over time, eliminate) spurious diffs.
  151. For Emacs users:
  152. (add-hook 'before-save-hook 'delete-trailing-whitespace)
  153. Naming conventions =================================================
  154. We use certain naming conventions to structure the considerable number
  155. of global identifiers. All identifiers should be either all lower
  156. case or all upper case. Syllables are separated by underscores `_'.
  157. All non-static identifiers should start with scm_ or SCM_. Then might
  158. follow zero or more syllables giving the category of the identifier.
  159. The currently used category identifiers are
  160. t - type name
  161. c,C - something with a interface suited for C use. This is used
  162. to name functions that behave like Scheme primitives but
  163. have a more C friendly calling convention.
  164. i,I - internal to libguile. It is global, but not considered part
  165. of the libguile API.
  166. f - a SCM variable pointing to a Scheme function object.
  167. F - a bit mask for a flag.
  168. m - a macro transformer procedure
  169. n,N - a count of something
  170. s - a constant C string
  171. k - a SCM variable pointing to a keyword.
  172. sym - a SCM variable pointing to a symbol.
  173. var - a SCM variable pointing to a variable object.
  174. The follwing syllables also have a technical meaning:
  175. str - this denotes a zero terminated C string
  176. mem - a C string with an explicit count