constant/constantp



Leo Butler wrote:
> On Wed, 22 Jul 2009, Richard Fateman wrote:
>
> < Leo Butler wrote:
> < > Is this a bug? That is, is the declaration that x is a constant expected
> < > to preclude assigment?
>  >   
> < I think this is not a bug,  0 is a constant, and 1 is a constant.
> < 
>  
> So the declaration 'constant' is not analogous to C's 'const'? It simply
> is expected that one can only assign constants to constants? If so, then 
> what about this:
>
> (%i2) define_variable(x,0,constant);
> modedeclare: warning: constant is not a built-in type; assuming it is a
> Maxima extension type.
> (%o2) 0
> (%i3) constantp(x);
> (%o3) true
> (%i4) constantp(y);
> (%o4) false
> (%i5) x:y;
> (%o5) y
>
> Leo
>
>   
The way I understand the declarations  (like float, ) is that they do 
not inhibit assignment of values that disagree with the declarations.
They are advice to the compiler that should enable it to compile code 
that is more specific, and will work faster.  If object of the wrong 
type are used, the computation may be incorrect.

A declaration like constant has no meaning until you (or someone else) 
tests for something having a feature "constant".

As far as constantp goes, constantp(x) above has nothing whatsoever to 
do with x.  x is 0, and constantp(0) is true.

constantp(y) is false because y is a symbol.

Perhaps the facility you might use in Maxima is  "alias" ,  say if you 
want to give a name like AvogadrosConstant  to some number.