[fpc-devel] const param documentation
Martin
fpc at mfriebe.de
Wed Oct 11 14:07:10 CEST 2017
https://www.freepascal.org/docs-html/current/ref/refsu67.html#x179-20100014.4.4
Just came to notice something....
But first: I had been under the impression, that if you
- define a param as const
- pass a global variable
- violate the contract, by modifying the global var while in the scope
of the const param
then you have written invalid code, and should expect the behaviour of
such code to be undefined.
On the link above it gives an example of such a situation (changing the
content of a string).
The example shows the current implemented behaviour. (the new value is
assigned to the const param, and the new value is used).
The documentation states: "This behaviour is by design"
That means according to the doc, such use of a constant param has a
defined and documented behaviour, and is a valid use case?
Should it not document, that it may print either value, or crash, or do
something else?
Meaning "By design this code is invalid, and has no defined behaviour"
More information about the fpc-devel
mailing list