]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/CodingStyle.pod
release: 0.0.30
[lilypond.git] / Documentation / CodingStyle.pod
1 =head1 NAME
2
3 CodingStyle - standards while programming for LilyPond
4
5 =head1 DESCRIPTION
6
7 Please use these standards while doing programming for LilyPond
8
9 Functions and methods do not return errorcodes, but use assert for
10 checking status. 
11
12 =head2 INDENTATION
13
14 in emacs:
15
16
17         (add-hook 'c-mode-hook
18                   '(lambda ()(setq c-basic-offset 4)))
19
20
21         (add-hook 'c++-mode-hook
22                   '(lambda() (c-set-style "Stroustrup")
23                      )
24                   )
25
26
27 =head2 CLASSES and TYPES:
28
29         This_is_a_class
30         AClass_name     (for Abbreviation_class_name)
31
32 =head2 DATA MEMBERS
33
34         Class::member()
35         Type Class::member_type_
36
37 the C<type> is a Hungarian notation postfix for $C<Type>$.
38
39
40 =head2 COMMENTS
41
42 The source is commented in the DOC++ style.  Check out doc++ at
43 http://www.zib.de/Visual/software/doc++/index.html
44
45         /// short description
46         class Class {
47                 /// short description
48                 /**
49                         long description
50                 */
51
52                 Data data_member_;
53                 /****************/
54
55                 /// short memo
56                 /**
57                         long doco of member()
58                 */
59                 member();
60         };
61         /**
62                 Class documentation.
63         */
64
65 Unfortunately most of the code isn't really documented that good.
66
67
68 =head2 CLASSNAMES (2)
69
70 A lot of classes in LilyPond start with 'P', this is to distinguish
71 certain parts of LilyPond: the P stands for Printer, and the P-classes
72 are supposed to be more lowlevel than the others. Example:
73
74 Staff uses PStaff, PScore and PCol to do the typesetting of
75 symbols. Staff is  the "brains" for PStaff
76
77 NB: in PCursor (which is part of the library) P stands for PointerCursor
78
79
80 =head2 MEMBERS(2)
81
82 Standard methods:
83
84         ///check that *this satisfies its invariants, abort if not.
85         void OK() const
86
87         /// print *this (and substructures) to debugging log
88         void print() const
89
90         /// add some data to *this; 
91         add( .. )
92         /**
93         Presence of these methods usually imply that it is not feasible to this
94         via  a constructor
95         */
96
97         /// replace some data of *this
98         set( .. )
99