The program mint, bundled with Maple, is a very useful syntax checker and program analyzer.

As provided, `mint` works best with Maple program source when contained in plaintext files. Inside Maple itself there is a command maplemint which does some of the same tasks as the stand-alone program `mint`. Unfortunately `maplemint` is quite a bit weaker than `mint` is, for quite a selection of procedures. Also, `maplemint` doesn't have the sort of flexible control that `mint` provides through its optional calling parameters.

I had previously posted a Maple language procedure for the purpose of calling out to `mint` while inside Maple (Standard GUI, or other). Here it is below, cleaned up a little. Hopefully it now works better across multiple operating systems, and also provides its optional parameters better.

mint := proc( f,
{level::posint:=2},
{toggle::list(posint):=[]},
{header::truefalse:=false},
{extras::string:=""} )
local fname,k,oldiface,executable;
fname := cat(kernelopts('homedir'),kernelopts('dirsep'),"minttemp.txt");
#fname := "/tmp/minttemp.txt"; # or some other temp location
oldiface := interface('verboseproc');
interface('verboseproc'=3);
writeto(fname);
printf("%a := %a:\n", f, eval(f));
writeto(terminal):
fclose(fname);
interface('verboseproc'=oldiface);
executable:=`if`(kernelopts('platform')="windows",
cat("\"",kernelopts('bindir'),"\\mint","\""),
cat(kernelopts('mapledir'),kernelopts('dirsep'),"bin/mint"));
k:=ssystem(cat(executable, cat(" -i ",min(level,4)," "),
seq(cat(" -t ",x," "), x in remove(t->t>32,toggle)),
`if`(not(header)," -q ",NULL),
" ",extras," ","\"",fname,"\""));
if k[1]>=0 then printf("%s",k[2]); end if;
NULL;
end proc:

Here are some examples of using it, including comparison with `maplemint`.

 > mint(`convert/CompSeq`);
Procedure convert/CompSeq( e1 ) on line 1
These local variables were used but never assigned a value: result

> #maplemint(`convert/CompSeq`); #crashes kernel, don't try it

> f:=proc(x) local y; A; y:=x; end proc:

> mint(f);
Procedure f( x ) on line 1
These names were used as global names but were not declared: A
These local variables were assigned a value, but otherwise unused: y

> mint(f,toggle=[9]);
Procedure f( x ) on line 1
These local variables were assigned a value, but otherwise unused: y

> mint(f,extras="-s -S");

> maplemint(f);
These names were used as global names, but were not declared:
A
These local variables were assigned a value, but otherwise unused:
y

> mint(`is/internal`);
Nested Anonymous Operator proc( a, b ) on line 1
These parameters were never used: b
Procedure is/internal( obj, prop ) on line 1
These names were used as global names but were not declared: hard
These global variables start with an _: _XXXXX

> maplemint(`is/internal`);
These names were used as global names, but were not declared:
_
These names were used as global names, but were not declared:
`property/object`
These names were used as global names, but were not declared:
`property/OrigName`
Error, (in maplemint/statement) invalid input: maplemint/updused uses a 2nd
argument, varlist, which is missing

Remember, always check your code.

 > mint(mint);
>

Suggestions for improvements are always welcome.

acer


Please Wait...