1Math::Symbolic::Custom(U3s)er Contributed Perl DocumentatMiaotnh::Symbolic::Custom(3)
2
3
4
6 Math::Symbolic::Custom - Aggregate class for tree tests and
7 transformations
8
10 # Extending the class:
11 package Math::Symbolic::Custom::MyTransformations;
12 use Math::Symbolic::Custom::Base;
13 BEGIN {*import = \&Math::Symbolic::Custom::Base::aggregate_import}
14
15 our $Aggregate_Export = [qw/apply_transformation1 .../];
16 sub apply_transformation1 {
17 # ...
18 }
19 # ...
20
21 # Using the custom class:
22 use Math::Symbolic;
23 use Math::Symbolic::Custom::MyTransformations;
24
25 # later...
26 $tree->apply_transformation1();
27 $tree->mod_transformation2();
28 die unless $tree->is_type1();
29 die unless $tree->test_condition1();
30 die if $tree->contains_something1();
31 print $tree->to_latex();
32
34 This is an aggregate class for all custom modification, transformation,
35 testing and output extensions for Math::Symbolic trees. Some default
36 transformations and tests are implemented in the
37 Math::Symbolic::Custom::DefaultMods and
38 Math::Symbolic::Custom::DefaultTests packages, default output routines
39 in Math::Symbolic::Custom::DefaultDumpers which are automatically
40 loaded by the Math::Symbolic::Custom class.
41
42 Math::Symbolic::Custom imports all constants from
43 Math::Symbolic::ExportConstants
44
45 EXPORT
46 None by default.
47
49 In order to extend the functionality of Math::Symbolic, you have to go
50 through the following steps: (also see the synopsis in this document.)
51
52 • Choose an appropriate namespace in the Math::Symbolic::Custom::*
53 hierarchy or if you desparately wish, somewhere else.
54
55 • Create a new module (probably using "h2xs -AX MODULENAME") and put
56 the following lines of code in it:
57
58 # To make sure we're cooperating with Math::Symbolic's idea of
59 # method delegation.
60 use Math::Symbolic::Custom::Base;
61 BEGIN {*import = \&Math::Symbolic::Custom::Base::aggregate_import}
62
63 our $Aggregate_Export = [
64 # Put the list of method names to be exported.
65 /];
66
67 • Think well about the naming of your exported methods. Answer the
68 following questions:
69
70 Does the name start with 'is_', 'test_', 'mod_', 'apply_',
71 'contains_', or 'to_'? If not, find a suitable name that does.
72
73 Does the name clash with any of the methods exported by
74 Math::Symbolic::Custom::DefaultTests,
75 Math::Symbolic::Custom::DefaultMods, or
76 Math::Symbolic::Custom::DefaultDumpers? If so, please consider
77 choosing a different name.
78
79 Does the name map to the idea behind the method prefix ('is_',
80 ...)? Only methods starting with one of the prefixes listed above
81 can be delegated. Any others will never be called. The idea behind
82 delegating methods with several prefixes is to provide for a
83 reasonable choice for naming methods. 'is_' and 'contains_' are
84 meant to be used for accurate tests like "is_constant". 'test_' is
85 meant for all tests that either make use of heuristics or can't be
86 fitted into either 'is_' or 'contains_'. The prefixes 'mod_' and
87 'apply_' are meant for use with methods that modify the
88 Math::Symbolic tree. Finally, the prefix 'to_' is meant to be used
89 with conversion and output methods like 'to_latex' or 'to_string'.
90 (Though as of version 0.122, to_string is implemented in the core
91 Math::Symbolic modules.)
92
93 • Make sure you document exactly what your methods do. Do they modify
94 the Math::Symbolic tree in-place or do they clone using the new()
95 constructor and return a copy? Make sure you mention the behaviour
96 in the docs.
97
98 • Consider packaging your extensions as a CPAN distribution to help
99 others in their development with Math::Symbolic. If you think the
100 extensions are generic enough to be a worthwhile addition to the
101 core distribution, try sending your extensions to the
102 Math::Symbolic developers mailing list instead.
103
104 • Load your extension module after loading the Math::Symbolic module.
105
106 • Start using your custom enhancements as methods to the
107 Math::Symbolic trees (any term types).
108
109 • Send bug reports and feedback to the Math::Symbolic support mailing
110 list.
111
113 Please send feedback, bug reports, and support requests to the
114 Math::Symbolic support mailing list: math-symbolic-support at lists dot
115 sourceforge dot net. Please consider letting us know how you use
116 Math::Symbolic. Thank you.
117
118 If you're interested in helping with the development or extending the
119 module's functionality, please contact the developers' mailing list:
120 math-symbolic-develop at lists dot sourceforge dot net.
121
122 List of contributors:
123
124 Steffen Mueller, symbolic-module at steffen-mueller dot net
125 Stray Toaster, mwk at users dot sourceforge dot net
126 Oliver Ebenhoeh
127
129 New versions of this module can be found on http://steffen-mueller.net
130 or CPAN. The module development takes place on Sourceforge at
131 http://sourceforge.net/projects/math-symbolic/
132
133 Math::Symbolic::Custom::Base Math::Symbolic::Custom::DefaultTests
134 Math::Symbolic::Custom::DefaultMods
135 Math::Symbolic::Custom::DefaultDumpers
136
137 Math::Symbolic
138
139
140
141perl v5.34.0 2021-07-22 Math::Symbolic::Custom(3)