Print

Print


> The TARGET tells the compiler to reserve storage, while the PARAMETER
> tells it that it can assume that it will never change.  Conceptually,
> the two are orthogonal.  The compiler can still perform constant
> folding, it just has to keep one copy in memory.

Normally, TARGET doesn't tell the compiler to reserve storage, since it
is an attribute of a variable which has storage for it reserved anyway.
It's main use is to let the compiler know what can in principle be
aliased, so that one isn't left with the choice, as in C, to either not
optimise or allow strange behaviour.  Since PARAMETER doesn't imply
storage, TARGET would have to tell the compiler to make it a "read-only
variable", perhaps implementing it quite differently than would
otherwise be the case.  It could be done, of course, but would require a
lot of implementations to change quite a bit with regard to PARAMETER,
or else implement TARGET PARAMETERs as an additional case. 

These days, possible efficiency advantages of PARAMETER as opposed to
variables are probably negligible.  The main advantage is that the
programmer cannot change their value by mistake.  I agree that constants
(the name PARAMETER is rather unfortunate) are conceptually quite
different from variables, like the distinction, and want an error if I
try to modify it, but in practice you could probably just have your
tables be variables and make sure that you don't try to modify them in
your code. 

This is similar to arrays of PARAMETERs in Fortran77.  Since this
feature didn't exist, one had to use variables, and just remember not to
change them. 


--
Phillip Helbig                       Email .............. [log in to unmask]
Kapteyn Instituut                    Email ................. [log in to unmask]
Rijksuniversiteit Groningen          Tel. ................... +31 50 363 6647
Postbus 800                          Fax .................... +31 50 363 6100
NL-9700 AV Groningen                 Web ... http://www.astro.rug.nl/~helbig/

My opinions are not necessarily those of my employer.

<A HREF=" http://gladia.astro.rug.nl:8000/helbig/hire/hire.html ">HIRE ME!</A>

Reward: one month of salary (yours or mine---take your pick)!



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%