Mercurial > hg > octave-lyh
annotate doc/interpreter/contrib.txi @ 8055:d51c3541be28
contrib.txi: new documentation for contributors
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 26 Aug 2008 11:00:09 -0400 |
parents | |
children | 65c4ac814082 |
rev | line source |
---|---|
8055
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
1 @c Copyright (C) 2008 Jaroslav Hajek <highegg@gmail.com> |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
2 @c |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
3 @c This file is part of Octave. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
4 @c |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
5 @c Octave is free software; you can redistribute it and/or modify it |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
6 @c under the terms of the GNU General Public License as published by the |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
7 @c Free Software Foundation; either version 3 of the License, or (at |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
8 @c your option) any later version. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
9 @c |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
10 @c Octave is distributed in the hope that it will be useful, but WITHOUT |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
13 @c for more details. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
14 @c |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
15 @c You should have received a copy of the GNU General Public License |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
16 @c along with Octave; see the file COPYING. If not, see |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
17 @c <http://www.gnu.org/licenses/>. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
18 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
19 @node Contributing Guidelines |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
20 @appendix Contributing Guidelines |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
21 @cindex coding standards |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
22 @cindex Octave development |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
23 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
24 This chapter is dedicated to those who wish to contribute code to Octave. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
25 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
26 @menu |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
27 * How to Contribute:: How you may start contributing code. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
28 * General Guidelines:: Advices applicable to any type of source. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
29 * Octave Sources (m-files):: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
30 * C++ Sources:: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
31 * Other Sources:: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
32 @end menu |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
33 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
34 @node How to Contribute |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
35 @section How to Contribute |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
36 The mailing list for Octave development discussion and sending contributions is |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
37 @email{maintainers@@octave.org}. This concerns the development of Octave core, |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
38 i.e. code that goes to Octave directly. You may consider developing and |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
39 publishing a package instead; a great place for this is the allied Octave-Forge |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
40 project (@url{http://octave.sf.net}). Note that the Octave project is |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
41 inherently more conservative and follows narrower rules. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
42 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
43 The preferable form of contribution is creating a Mercurial changeset and |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
44 sending it via e-mail to the octave-maintainers mailing list. Mercurial is the |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
45 SCM system currently used to develop Octave. Other forms of contributions (e.g. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
46 simple diff patches) are also acceptable, but they slow down the review process. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
47 If you want to make more contributions, you should really get familiar with |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
48 Mercurial. A good place to start is |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
49 @url{http://www.selenic.com/mercurial/wiki/index.cgi/Tutorial}. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
50 A simplified contribution sequence could look like this: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
51 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
52 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
53 hg clone http://www.octave.org/hg/octave |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
54 cd octave |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
55 # change some sources... |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
56 hg commit -m "make Octave the coolest software ever" |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
57 hg export ../cool.diff |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
58 # send ../cool.diff via email |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
59 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
60 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
61 @node General Guidelines |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
62 @section General Guidelines |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
63 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
64 All Octave's sources are distributed under the General Public License (GPL). |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
65 Currently, Octave uses GPL version 3. For details about this license, see |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
66 @url{http://www.gnu.org/licenses/gpl.html}. Therefore, whenever you create a |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
67 new source file, it should have the following comment header (use appropriate |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
68 year, name and comment marks): |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
69 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
70 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
71 ## Copyright (C) 1996, 1997, 2007 John W. Eaton <jwe@@bevo.che.wisc.edu> |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
72 ## |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
73 ## This file is part of Octave. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
74 ## |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
75 ## Octave is free software; you can redistribute it and/or |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
76 ## modify it under the terms of the GNU General Public |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
77 ## License as published by the Free Software Foundation; |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
78 ## either version 3 of the License, or (at your option) any |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
79 ## later version. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
80 ## |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
81 ## Octave is distributed in the hope that it will be useful, |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
82 ## but WITHOUT ANY WARRANTY; without even the implied |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
83 ## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
84 ## PURPOSE. See the GNU General Public License for more |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
85 ## details. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
86 ## |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
87 ## You should have received a copy of the GNU General Public |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
88 ## License along with Octave; see the file COPYING. If not, |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
89 ## see <http://www.gnu.org/licenses/>. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
90 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
91 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
92 Always include ChangeLog entries in changesets. After making your source |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
93 changes, record and briefly describe the changes in the nearest ChangeLog file |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
94 upwards in the directory tree. Use the previous entries as a template. Your |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
95 entry should contain your name and email, and the path to the modified source |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
96 file relative to the parent directory of the ChangeLog file. If there are more |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
97 functions in the file, you should also include the name of the modified function |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
98 (in parentheses after file path). Example: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
99 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
100 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
101 2008-04-02 David Bateman <dbateman@@free.fr> |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
102 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
103 * graphics.cc (void gnuplot_backend::close_figure (const |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
104 octave_value&) const): Allow for an input and output stream. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
105 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
106 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
107 @noindent |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
108 The ChangeLog entries should describe what is changed, not why. The reason of |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
109 the change should appear in the commit message. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
110 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
111 @node Octave Sources (m-files) |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
112 @section Octave Sources (m-files) |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
113 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
114 Don't use tabs. Tabs cause trouble. If you are used to them, set up your editor |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
115 so that it converts tabs to spaces. Indent the bodies of the statement blocks. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
116 Recommended indent is 2 spaces. When calling functions, put spaces after commas |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
117 and before the calling parentheses, like this: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
118 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
119 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
120 x = max (sin (y+3), 2); |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
121 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
122 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
123 @noindent |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
124 An exception are matrix and vector constructors: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
125 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
126 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
127 [sin(x), cos(x)] |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
128 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
129 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
130 @noindent |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
131 Here, putting spaces after @code{sin}, @code{cos} would result in a parse error. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
132 In indexing expression, do not put a space after the identifier (this |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
133 differentiates indexing and function calls nicely). The space after comma is not |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
134 necessary if index expressions are simple, i.e. you may write |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
135 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
136 A(:,i,j) |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
137 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
138 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
139 @noindent |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
140 but |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
141 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
142 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
143 A([1:i-1;i+1:n], XI(:,2:n-1)) |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
144 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
145 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
146 Use lowercase names if possible. Uppercase is acceptable for variable names |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
147 consisting of 1-2 letters. Do not use mixed case names. Function names must be |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
148 lowercase. Function names are global, so choose them wisely. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
149 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
150 Always use a specific end-of-block statement (like @code{endif}, |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
151 @code{endswitch}) rather than generic @code{end}. Enclose the @code{if}, |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
152 @code{while}, @code{until} and @code{switch} conditions in parentheses, |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
153 like in C: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
154 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
155 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
156 if (isvector (a)) |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
157 s = sum(a); |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
158 endif |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
159 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
160 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
161 @noindent |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
162 Do not do this, however, with @code{for}: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
163 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
164 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
165 for i = 1:n |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
166 b(i) = sum (a(:,i)); |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
167 endfor |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
168 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
169 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
170 @node C++ Sources |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
171 @section C++ Sources |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
172 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
173 Don't use tabs. Tabs cause trouble. If you are used to them, set up your editor |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
174 so that it converts tabs to spaces. Format function headers like this: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
175 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
176 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
177 static bool |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
178 matches_patterns (const string_vector& patterns, int pat_idx, |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
179 int num_pat, const std::string& name) |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
180 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
181 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
182 @noindent |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
183 The function name should start in column 1, and multi-line argument lists should |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
184 be aligned on the first char after the open parenthesis. You should put a space |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
185 after the left open parenthesis and after commas, for both function definitions |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
186 and function calls. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
187 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
188 Recommended indent is 2 spaces. When indenting, indent the statement after |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
189 control structures (like @code{if}, @code{while} etc.). If there is a compound |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
190 statement, indent @i{both} the curly braces and the body of the statement (so |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
191 that the body gets indented by @i{two} indents). Example: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
192 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
193 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
194 if (have_args) |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
195 @{ |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
196 idx.push_back (first_args); |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
197 have_args = false; |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
198 @} |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
199 else |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
200 idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp)); |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
201 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
202 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
203 @noindent |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
204 If you have nested @code{if} statements, use extra braces for extra |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
205 clarification. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
206 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
207 Split long expressions in such a way that a continuation line starts with an |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
208 operator rather than identifier. If the split occurs inside braces, continuation |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
209 should be aligned with the first char after the innermost braces enclosing the |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
210 split. Example: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
211 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
212 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
213 SVD::type type = ((nargout == 0 || nargout == 1) |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
214 ? SVD::sigma_only |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
215 : (nargin == 2) ? SVD::economy : SVD::std); |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
216 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
217 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
218 @noindent |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
219 Consider putting extra braces around a multiline expression to make it more |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
220 readable, even if they are not necessary. Also, do not hesitate to put extra |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
221 braces anywhere if it improves clarity. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
222 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
223 Try declaring variables just before they're needed. Use local variables of |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
224 blocks - it helps optimization. Don't write multi-line variable declaration |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
225 with a single type specification and multiple variables. If the variables don't |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
226 fit on single line, repeat the type specification. Example: |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
227 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
228 @example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
229 octave_value retval; |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
230 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
231 octave_idx_type nr = b.rows (); |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
232 octave_idx_type nc = b.cols (); |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
233 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
234 double d1, d2; |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
235 @end example |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
236 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
237 Use lowercase names if possible. Uppercase is acceptable for variable names |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
238 consisting of 1-2 letters. Do not use mixed case names. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
239 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
240 Try to use Octave's types and classes if possible. Otherwise, try to use C++ |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
241 standard library. Use of STL containers and algorithms is encouraged. Use |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
242 templates wisely to reduce code duplication. Avoid comma expressions, labels |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
243 and gotos, and explicit typecasts. If you need to typecast, use the modern C++ |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
244 casting operators. In functions, try to reduce the number of @code{return} |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
245 statements - use nested @code{if} statements if possible. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
246 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
247 @node Other Sources |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
248 @section Other Sources |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
249 Apart from C++ and Octave language (m-files), Octave's sources include files |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
250 written in C, Fortran, M4, perl, unix shell, AWK, texinfo and TeX. There are |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
251 not many rules to follow when using these other languages; some of them are |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
252 summarized below. In any case, the golden rule is: if you modify a source |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
253 file, try to follow any conventions you can detect in the file or other similar |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
254 files. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
255 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
256 For C you should obviously follow all C++ rules that can apply. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
257 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
258 If you happen to modify a Fortran file, you should stay within Fortran 77 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
259 with common extensions like @code{END DO}. Currently, we want all sources |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
260 to be compilable with the f2c and g77 compilers, without special flags if |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
261 possible. This usually means that non-legacy compilers also accept the sources. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
262 |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
263 The M4 macro language is mainly used for autoconf configuration files. You should |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
264 follow normal M4 rules when contributing to these files. Some M4 files come |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
265 from external source, namely the Autoconf archive @url{http://autoconf-archive.cryp.to}. |
d51c3541be28
contrib.txi: new documentation for contributors
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
266 |