HACKING 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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, available at
  74. https://www.gnu.org/prep/standards/standards.html.
  75. - The Guile tree should compile without warnings under the following
  76. GCC switches, which are the default in the current configure script:
  77. -O2 -Wall -Wpointer-arith -Wmissing-prototypes
  78. To make sure of this, you can use the --enable-error-on-warning option
  79. to configure. This option will make GCC fail if it hits a warning.
  80. Note that the warnings generated vary from one version of GCC to the
  81. next, and from one architecture to the next. For this reason,
  82. --enable-error-on-warning is not enabled by default.
  83. - If you add code which uses functions or other features that are not
  84. entirely portable, please make sure the rest of Guile will still
  85. function properly on systems where they are missing. This usually
  86. entails adding a test to configure.in, and then adding #ifdefs to your
  87. code to disable it if the system's features are missing. Do check first
  88. if the function has a Gnulib wrapper, though.
  89. - The normal way of removing a function, macro or variable is to mark
  90. it as "deprecated", keep it for a while, and remove it in a later
  91. release. If a function or macro is marked as "deprecated" it
  92. indicates that people shouldn't use it in new programs, and should try
  93. to remove it in old. Make sure that an alternative exists unless it
  94. is our purpose to remove functionality. Don't deprecate definitions
  95. if it is unclear when they will be removed. (This is to ensure that a
  96. valid way of implementing some functionality always exists.)
  97. When deprecating a definition, always follow this procedure:
  98. 1. Mark the definition using
  99. #if (SCM_DEBUG_DEPRECATED == 0)
  100. ...
  101. #endif
  102. or, for Scheme code, wrap it using
  103. (begin-deprecated
  104. ...)
  105. 2. Make the deprecated code issue a warning when it is used, by using
  106. scm_c_issue_deprecation_warning (in C) or issue-deprecation-warning
  107. (in Scheme).
  108. 3. Write a comment at the definition explaining how a programmer can
  109. manage without the deprecated definition.
  110. 4. Add an entry that the definition has been deprecated in NEWS and
  111. explain what to do instead.
  112. - Write commit messages for functions written in C using the
  113. functions' C names, and write entries for functions written in Scheme
  114. using the functions' Scheme names. For example,
  115. * foo.c: Moved scm_procedure_documentation from eval.c.
  116. is preferred over
  117. * foo.c: Moved procedure-documentation from eval.c.
  118. Changes like adding this line are special:
  119. SCM_PROC (s_map_in_order, "map-in-order", 2, 0, 1, scm_map);
  120. Since the change here is about the name itself --- we're adding a new
  121. alias for scm_map that guarantees the order in which we process list
  122. elements, but we're not changing scm_map at all --- it's appropriate
  123. to use the Scheme name in the commit message.
  124. - Make sure you have papers from people before integrating their
  125. changes or contributions. This is very frustrating, but very
  126. important to do right. From maintain.texi, "Information for
  127. Maintainers of GNU Software":
  128. When incorporating changes from other people, make sure to follow the
  129. correct procedures. Doing this ensures that the FSF has the legal
  130. right to distribute and defend GNU software.
  131. For the sake of registering the copyright on later versions ofthe
  132. software you need to keep track of each person who makes significant
  133. changes. A change of ten lines or so, or a few such changes, in a
  134. large program is not significant.
  135. *Before* incorporating significant changes, make sure that the person
  136. has signed copyright papers, and that the Free Software Foundation has
  137. received them.
  138. If you receive contributions you want to use from someone, let a
  139. maintainer know and they will take care of the administrivia. Put the
  140. contributions aside until we have the necessary papers.
  141. Once you accept a contribution, be sure to keep the files AUTHORS and
  142. THANKS up-to-date.
  143. - When you make substantial changes to a file, add the current year to
  144. the list of years in the copyright notice at the top of the file.
  145. - When you get bug reports or patches from people, be sure to list
  146. them in THANKS.
  147. - Do not introduce trailing whitespace (and feel free to clean it up
  148. opportunistically, that is, if doing so is part of some other change).
  149. The goal is to reduce (and over time, eliminate) spurious diffs.
  150. For Emacs users:
  151. (add-hook 'before-save-hook 'delete-trailing-whitespace)
  152. Naming conventions =================================================
  153. We use certain naming conventions to structure the considerable number
  154. of global identifiers. All identifiers should be either all lower
  155. case or all upper case. Syllables are separated by underscores `_'.
  156. All non-static identifiers should start with scm_ or SCM_. Then might
  157. follow zero or more syllables giving the category of the identifier.
  158. The currently used category identifiers are
  159. t - type name
  160. c,C - something with a interface suited for C use. This is used
  161. to name functions that behave like Scheme primitives but
  162. have a more C friendly calling convention.
  163. i,I - internal to libguile. It is global, but not considered part
  164. of the libguile API.
  165. f - a SCM variable pointing to a Scheme function object.
  166. F - a bit mask for a flag.
  167. m - a macro transformer procedure
  168. n,N - a count of something
  169. s - a constant C string
  170. k - a SCM variable pointing to a keyword.
  171. sym - a SCM variable pointing to a symbol.
  172. var - a SCM variable pointing to a variable object.
  173. The follwing syllables also have a technical meaning:
  174. str - this denotes a zero terminated C string
  175. mem - a C string with an explicit count