Question: global names collapse with built-in name +how to debug error ? (Statistics/ProbabilityTable)


======================== This code will give error ============






I  used Maple12 and had a hard time debugging my code to find the error . Finally, I found that when we assign the name i a value, then the RandomVariable(ProbabilityTable([...]) will give error message below:

Error, (in Statistics:-Distribution) summation variable previously assigned, second argument evaluates to 1 = 1 .. 2

that means the name i also be used in the ProbabilityTable code. So how do we know which names we could use as global vars and won't collapse with the  names used in the built-in package ??

By the way, I would like to know what  is the fastest way we could detect the source of hard-to-find errors in the code since the error could come from some multilevel nested internal functions (for ex, RandomVariable() will call Distribution() and Distribution() will call sth else internally and this sth will call sth else ... but the sths we don't understand the code since there are no help pages for them).  I tried to use stoperror(all) but it only stop at the "catch: error..." and the Debugger GUI don't let us to go back to the place where the error happens .  I tried to use printlevel:=500; but the printout shows a messy stuff of hundred lines of multiple nested built-in functions. The error may be shown to happen when a function at level 50 (for  ex) is called, but this function receives the output of function at level 49... (so the error could happen in function at level 49,48,47.... but how can we know which function is the source of the error except we test each function one-by-one . But know that those are the built-in functions which can't be found in the help page).

For ex: I see in the trace: functionA(x, 1=1..5), so 1=1..5 is the error but some other functionB will pass this 1=1..5 to functionA, so we need to trace back to functionB, then functionC which pass error to functionB,..... and this will take long time.

I mean may be there is no fastest way to dectect...?


Please Wait...