1 | |
---|
2 | version="$Id: buglib3.lib $"; |
---|
3 | category="General purpose"; |
---|
4 | info=" |
---|
5 | LIBRARY: bugexample.lib Shows bug with map declaration and example part |
---|
6 | |
---|
7 | |
---|
8 | PROCEDURES: goodproc(f); return f via identity map |
---|
9 | goodproc2(f); return f via identity map |
---|
10 | badproc(f); return f via identity map |
---|
11 | |
---|
12 | DESCRIPTION: Without an explicit 'def d = basering' inside the proc definition, |
---|
13 | the definition of a map may refer a wrong ring accesses wrong |
---|
14 | objects. |
---|
15 | "; |
---|
16 | ////////////////////////////////////////////////////////////////////////////// |
---|
17 | |
---|
18 | proc badproc(poly f) |
---|
19 | "USAGE: badproc(f); f poly; |
---|
20 | RETURN: poly, the input |
---|
21 | EXAMPLE: example badproc; shows an example |
---|
22 | " |
---|
23 | { |
---|
24 | // def d = basering; // this should not be required, but |
---|
25 | // due to a bug with map and the example part, it is necessary |
---|
26 | map phi; |
---|
27 | poly g; |
---|
28 | phi = basering,maxideal(1); |
---|
29 | "hello"; |
---|
30 | basering; |
---|
31 | listvar(); // This listvar is not excuted(?) without def d = basering above |
---|
32 | "-- end"; |
---|
33 | g = phi(f); |
---|
34 | return(g); |
---|
35 | } |
---|
36 | example |
---|
37 | { "EXAMPLE:"; echo = 2; |
---|
38 | |
---|
39 | ring r = 0,(x,y),dp; |
---|
40 | poly h = 2x3y4 + x5+ y3; |
---|
41 | listvar(); |
---|
42 | badproc(h); |
---|
43 | } |
---|
44 | /////////////////////////////////////////////////////////////////////////////// |
---|
45 | |
---|
46 | proc goodproc(poly f) |
---|
47 | "USAGE: goodproc(f); f poly; |
---|
48 | RETURN: poly, the input |
---|
49 | EXAMPLE: example goodproc; shows an example |
---|
50 | " |
---|
51 | { |
---|
52 | def d = basering; // with this definition it is OK |
---|
53 | map phi; |
---|
54 | poly g; |
---|
55 | phi = basering,maxideal(1); // doesn't refer explicitely to d, but OK |
---|
56 | "hello"; |
---|
57 | basering; |
---|
58 | listvar(); // this listvar works here |
---|
59 | "-- end"; |
---|
60 | g = phi(f); |
---|
61 | return(g); |
---|
62 | } |
---|
63 | example |
---|
64 | { "EXAMPLE:"; echo = 2; |
---|
65 | |
---|
66 | ring r = 0,(x,y),dp; |
---|
67 | poly h = 2x3y4 + x5+ y3; |
---|
68 | listvar(); |
---|
69 | goodproc(h); |
---|
70 | } |
---|
71 | /////////////////////////////////////////////////////////////////////////////// |
---|
72 | |
---|
73 | proc goodproc2(poly f) |
---|
74 | "USAGE: goodproc2(f); f poly; |
---|
75 | RETURN: poly, the input |
---|
76 | EXAMPLE: example goodproc2; shows an example |
---|
77 | " |
---|
78 | { |
---|
79 | def d = basering; // with this definition it is OK |
---|
80 | map phi; |
---|
81 | poly g; |
---|
82 | phi = d,maxideal(1); // refer to d |
---|
83 | "hello"; |
---|
84 | basering; |
---|
85 | listvar(); // this listvar works here |
---|
86 | "-- end"; |
---|
87 | g = phi(f); |
---|
88 | return(g); |
---|
89 | } |
---|
90 | example |
---|
91 | { "EXAMPLE:"; echo = 2; |
---|
92 | |
---|
93 | ring r = 0,(x,y),dp; |
---|
94 | poly h = 2x3y4 + x5+ y3; |
---|
95 | listvar(); |
---|
96 | goodproc2(h); |
---|
97 | } |
---|
98 | /////////////////////////////////////////////////////////////////////////////// |
---|
99 | |
---|
100 | /* |
---|
101 | Extended description: |
---|
102 | |
---|
103 | The procs goodproc, goodproc2, badproc do nothing else than to return |
---|
104 | the input polynomial after having called the identity map via |
---|
105 | phi = basering,maxideal(1); |
---|
106 | |
---|
107 | Suppose that there is ring defined with the same name as that defined in |
---|
108 | the example part. |
---|
109 | Then the problem occurs that, when calling the example part, Singular |
---|
110 | might access to the userdefined ring, but not to that of the example. |
---|
111 | |
---|
112 | This, see proc badproc, has the following effect: |
---|
113 | 1.) Either example stops with an ERROR since outside there is no object |
---|
114 | with that name as in the example, or |
---|
115 | 2.) it choose the object from the userdefined ring, in case an object |
---|
116 | equally named as in the *argumentlist* of the proc exists. |
---|
117 | |
---|
118 | To avoid this side effect, see proc goodproc, one has to write explicitely |
---|
119 | def d = basering; |
---|
120 | before defining the map. However the 'd' itself has not to be used in the |
---|
121 | definition of the map. I.e. |
---|
122 | map phi = basering,maxideal(1); |
---|
123 | is enough, it is not necessary to write |
---|
124 | map phi = d,maxideal(1); |
---|
125 | |
---|
126 | |
---|
127 | The example part contains: |
---|
128 | ring r = 0,(x,y),dp; |
---|
129 | poly h = 2x3y4 + x5+ y3; |
---|
130 | |
---|
131 | and the argumentlist is (poly f). |
---|
132 | */ |
---|
133 | |
---|
134 | /* |
---|
135 | |
---|
136 | // Input file badlib3.in |
---|
137 | LIB "badlib3.lib"; |
---|
138 | basering; |
---|
139 | |
---|
140 | example badproc; |
---|
141 | example goodproc; |
---|
142 | |
---|
143 | // Everything fine upto here. |
---|
144 | |
---|
145 | // Now define a ring with the same name in the example. |
---|
146 | ring r=0,(x,y,z),dp; |
---|
147 | example goodproc; |
---|
148 | // example goodproc; // gives the same good result as goodproc |
---|
149 | example badproc; // ERROR - interrupt undefined object f (!?) |
---|
150 | // f is the name from the argument list !! |
---|
151 | |
---|
152 | |
---|
153 | // Now if we define such a poly f: |
---|
154 | poly f = x2+y3+z4; |
---|
155 | example badproc; // again ERROR, Singular accesses *this* poly f |
---|
156 | // but uses the maxideal(1) from the twovariable ring |
---|
157 | // as declared in the example! |
---|
158 | //example goodproc; |
---|
159 | //example goodproc2; |
---|
160 | */ |
---|
161 | |
---|
162 | /* |
---|
163 | // Output file badlib3.out |
---|
164 | > LIB"badlib3.lib"; |
---|
165 | // ** loaded badlib3.lib ($",?) |
---|
166 | > basering; |
---|
167 | ? `basering` is undefined |
---|
168 | ? error occurred in or before STDIN line 2: `basering;` |
---|
169 | > example badproc; |
---|
170 | // proc badproc from lib badlib3.lib |
---|
171 | EXAMPLE: |
---|
172 | |
---|
173 | ring r = 0,(x,y),dp; |
---|
174 | poly h = 2x3y4 + x5+ y3; |
---|
175 | listvar(); |
---|
176 | // r [1] *ring |
---|
177 | // h [1] poly |
---|
178 | badproc(h); |
---|
179 | hello |
---|
180 | // characteristic : 0 |
---|
181 | // number of vars : 2 |
---|
182 | // block 1 : ordering dp |
---|
183 | // : names x y |
---|
184 | // block 2 : ordering C |
---|
185 | -- end |
---|
186 | 2x3y4+x5+y3 |
---|
187 | |
---|
188 | > example goodproc; |
---|
189 | // proc goodproc from lib badlib3.lib |
---|
190 | EXAMPLE: |
---|
191 | |
---|
192 | ring r = 0,(x,y),dp; |
---|
193 | poly h = 2x3y4 + x5+ y3; |
---|
194 | listvar(); |
---|
195 | // r [1] *ring |
---|
196 | // h [1] poly |
---|
197 | goodproc(h); |
---|
198 | hello |
---|
199 | // characteristic : 0 |
---|
200 | // number of vars : 2 |
---|
201 | // block 1 : ordering dp |
---|
202 | // : names x y |
---|
203 | // block 2 : ordering C |
---|
204 | // d [2] *ring |
---|
205 | // g [2] poly |
---|
206 | // phi [2] map from d |
---|
207 | // f [2] poly |
---|
208 | // h [1] poly |
---|
209 | -- end |
---|
210 | 2x3y4+x5+y3 |
---|
211 | |
---|
212 | > ring r=0,(x,y,z),dp; |
---|
213 | > example goodproc; |
---|
214 | // proc goodproc from lib badlib3.lib |
---|
215 | EXAMPLE: |
---|
216 | |
---|
217 | ring r = 0,(x,y),dp; |
---|
218 | poly h = 2x3y4 + x5+ y3; |
---|
219 | listvar(); |
---|
220 | // r [1] *ring |
---|
221 | // h [1] poly |
---|
222 | // r [0] ring |
---|
223 | goodproc(h); |
---|
224 | hello |
---|
225 | // characteristic : 0 |
---|
226 | // number of vars : 2 |
---|
227 | // block 1 : ordering dp |
---|
228 | // : names x y |
---|
229 | // block 2 : ordering C |
---|
230 | // d [2] *ring |
---|
231 | // g [2] poly |
---|
232 | // phi [2] map from d |
---|
233 | // f [2] poly |
---|
234 | // h [1] poly |
---|
235 | -- end |
---|
236 | 2x3y4+x5+y3 |
---|
237 | |
---|
238 | > example badproc; |
---|
239 | // proc badproc from lib badlib3.lib |
---|
240 | EXAMPLE: |
---|
241 | |
---|
242 | ring r = 0,(x,y),dp; |
---|
243 | poly h = 2x3y4 + x5+ y3; |
---|
244 | listvar(); |
---|
245 | // r [1] *ring |
---|
246 | // h [1] poly |
---|
247 | // r [0] ring |
---|
248 | badproc(h); |
---|
249 | hello |
---|
250 | // characteristic : 0 |
---|
251 | // number of vars : 2 |
---|
252 | // block 1 : ordering dp |
---|
253 | // : names x y |
---|
254 | // block 2 : ordering C |
---|
255 | -- end |
---|
256 | ? f undefined in r |
---|
257 | ? error occurred in or before badlib3.lib::badproc line 32: ` g = phi(f);` |
---|
258 | ? leaving badlib3.lib::badproc |
---|
259 | skipping text from `;` error at token `)` |
---|
260 | ? leaving badlib3.lib::badproc |
---|
261 | |
---|
262 | > poly f = x2+z; |
---|
263 | > example badproc; |
---|
264 | // proc badproc from lib badlib3.lib |
---|
265 | EXAMPLE: |
---|
266 | |
---|
267 | ring r = 0,(x,y),dp; |
---|
268 | poly h = 2x3y4 + x5+ y3; |
---|
269 | listvar(); |
---|
270 | // r [1] *ring |
---|
271 | // h [1] poly |
---|
272 | // r [0] ring |
---|
273 | badproc(h); |
---|
274 | hello |
---|
275 | // characteristic : 0 |
---|
276 | // number of vars : 2 |
---|
277 | // block 1 : ordering dp |
---|
278 | // : names x y |
---|
279 | // block 2 : ordering C |
---|
280 | -- end |
---|
281 | x2 |
---|
282 | |
---|
283 | |
---|
284 | > example goodproc; |
---|
285 | // proc goodproc from lib badlib3.lib |
---|
286 | EXAMPLE: |
---|
287 | |
---|
288 | ring r = 0,(x,y),dp; |
---|
289 | poly h = 2x3y4 + x5+ y3; |
---|
290 | listvar(); |
---|
291 | // r [1] *ring |
---|
292 | // h [1] poly |
---|
293 | // r [0] ring |
---|
294 | goodproc(h); |
---|
295 | hello |
---|
296 | // characteristic : 0 |
---|
297 | // number of vars : 2 |
---|
298 | // block 1 : ordering dp |
---|
299 | // : names x y |
---|
300 | // block 2 : ordering C |
---|
301 | // d [2] *ring |
---|
302 | // g [2] poly |
---|
303 | // phi [2] map from d |
---|
304 | // f [2] poly |
---|
305 | // h [1] poly |
---|
306 | -- end |
---|
307 | 2x3y4+x5+y3 |
---|
308 | |
---|
309 | |
---|
310 | */ |
---|