|
From: Arthur N. <ac...@ca...> - 2014-10-24 07:22:00
|
I am replying to this via the general list first in case it is useful to
anybody else and secondly because an attempt at a direct response saw my
email bounced, so I hope this is a way to get through.
On Thu, 23 Oct 2014, Kostas Oikonomou wrote:
> Is it possible to define a "constant" in your module and use it as an
> error number in 'rerror(...)'?
> 'rerror' seems to require a literal integer. Managing error numbers by
> literal integers is difficult.
> So I'd like to be able to say smth. like
> listerr := 1
> ...
> if not listp(bounds) or length(bounds) neq n+1 then
> rerror('nlopt, listerr, {"list of size", n, "expected!"});
> But doing this results in
> ***** liberr invalid as RERROR argument
> Thanks.
> Kostas
The effect you observe arises in formrerror in rlisp/form.red which is
imposing constraints on the arguments to rerror and permitting us without a
quote of arg1.
symbolic procedure formrerror(u,vars,mode);
begin scalar x;
argnochk u;
if not fixp caddr u then typerr(caddr u,"RERROR argument");
x := formc!*(cadddr u,vars,mode);
if idp cadr u then return list('rerror,mkquote cadr u,caddr u,x)
else if eqcar(cadr u,'quote) and idp cadadr u
then return list('rerror,cadr u,caddr u,x)
else typerr(cadr u,"RERROR argument")
end;
so that indeed explicitly insists on a literal numeric argument.
If you look in rlisp/lpri.red you see
symbolic procedure rerror(packagename,number,message);
progn(errmsg!* := message, rederr message);
and rerror discards/ignores its first two arguments, so there is to my mind
little huge purpose of using it rather then just calling rederr directly!
Arthur
|