While I admire the cleverness of transferring (all) output to some other
stream to avoid messages, it seems to me that this is really not the
right approach.
Better would be to look at all the code that does "messages" and use one
of a very few standard mechanisms.
Some or perhaps all of these messages could be diverted or muffled on
setting on some flags.
Possible categories:
Emergency -- the program is going to quit. If you don't see this you
will be wondering what happened, so you can't muffle this.
Requires response - e.g. the much disliked "is abc pos neg or
zero?" If you muffle this, the program cannot continuge.
Warning - e.g. Principal value
Info - e.g. some roots may be multiple?
regularly displayed - e.g. %o14 or (%i15) .
{what else?}
Also, it would be nice if each message had a unique number so that an
index of all messages could be assembled,
with an explanation of their meaning, and a user could easily find the
explanation.
e.g.
[integrate001] Principal Value
[compare001] Is abc pos neg zero
[rat001] rat replaced 0.5 by 1/2
On 11/4/2011 10:13 AM, Edwin Woollett wrote:
> I am experimenting with a way to surpress messages
> from integrate, using with_stdout inside another
> function.
>
> Here is a simple example which does not succeed in
> getting with_stdout to work inside another function.
>
> quiet_mode (file,expr) is designed to emulate the
> classical black hole effect of using "/dev/null" as the
> destination file in a unix system.
>
> In this example, I want to surpress the 'Principal Value'
> message from integrate.
>
> (%i1) load("quiet-mode.mac");
> (%o1) "quiet-mode.mac"
>
> (%i2) file_search("zzz123");
> (%o2) false
>
> /* use of with_stdout inside quiet_mode does nothing */
>
> (%i3) quiet_mode("zzz123",
> integrate(sin(x)*(sin(x^2)*(sin(x^3)+1/x)+1/x),x,0,inf));
>
> Principal Value
>
> (%o3) 'integrate(sin(x)*(sin(x^2)*(sin(x^3)+1/x)+1/x),x,0,inf)
>
> (%i4) fundef(quiet_mode);
> (%o4) quiet_mode(ffile,e):=block([rr],rr:apply('with_stdout,[ffile,e]),
> ?delete\-file(ffile),rr)
>
> (%i5) file_search("zzz123");
> (%o5) false
>
> /* interactive use of with_stdout surpresses the message */
>
> (%i6) with_stdout ("zzz123",
> integrate(sin(x)*(sin(x^2)*(sin(x^3)+1/x)+1/x),x,0,inf));
>
> (%o6) 'integrate(sin(x)*(sin(x^2)*(sin(x^3)+1/x)+1/x),x,0,inf)
>
> (%i7) file_search("zzz123");
> (%o7) "zzz123"
>
> (%i8) printfile("zzz123")$
> Principal Value
> ---------------------------------
>
> Ted Woollett
> p.s. file quiet-mode.mac
> -----------------------------
> /* quiet-mode.mac */
>
> quiet_mode (ffile,e) :=
> block ([rr],
> rr: apply ('with_stdout, [ffile,e]),
> ?delete\-file (ffile),
> rr)$
> display2d:false$
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima