Protecting variables



Question - wouldn't this be a good ability to add as a standard feature
in Maxima (i.e. - not something that needs to be specially loaded?)  I
can think of many cases where this would be useful for topic specific
packages (the physical constants package for example.)  Also, maybe it
would be useful to have two degrees of protection?  Something like:

(C1) lock(a);
(D1)                               NEVERSET
(C2) a : 5;
Improper value assignment to a
 -- an error.  Quitting.  To debug this try DEBUGMODE(TRUE);)
(C3) unlock(a);
(D3)                                 TRUE
(C4) a : 5;
(D4)                                   5
(C5) protect(a);
(D5)                               PROTECTSET
(C6) a : 3;
a is a protected symbol.  Are you sure you wish to make this
assignment?
no;
(D6)                                FALSE
(C7) a : 3;
a is a protected symbol.  Are you sure you wish to make this
assignment?
yes;
(D7)                                   5
(C8) unprotect(a);
(D8)                                 FALSE
(C9) protect(a);
(D9)                               PROTECTSET
(C10) a : 3;
a is a protected symbol.  Are you sure you wish to make this
assignment?
no;
(D10)                                FALSE
(C11) unprotect(a);
(D11)                                 TRUE
(C12) a : 6;
(D12)                                   6

Possibly locked vs. protected isn't a useful distinction, but I thought
I'd see if anyone else thought it was a useful idea.

CY

--- Barton Willis <willisb@unk.edu> wrote:
> Thank you for the advice; yes, symbolp is much better.
> 
> (defun $protect (x)
>   (if (symbolp x)
>       (putprop x 'neverset 'assign)
>     (merror "Argument to protect must be a symbol")))
> 
> (defun $unprotect (x)
>   (if (symbolp x) (remprop x 'assign)
>     (merror "Argument to unprotect must be a symbol")))
> 
> 
> Barton
> 
> 
> 
> 
> Steve Haflich <smh@franz.com>
> 01/30/2004 02:35 PM
> Please respond to smh
> 
>  
>         To:     Barton Willis <willisb@unk.edu>
>         cc:     lmarquez@cicese.mx, maxima@www.ma.utexas.edu
>         Subject:        Re: [Maxima] Protecting variables
> 
> 
> 
> Is atom the right predicate here?  In Common Lisp everything except a
> cons is an atom.  Wouldn't symbolp be more conservative, rather than
> 
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/