The meaning of const will not change in future versions.
You are interpreting what PascalDragon said a different way than I am. He said :
Also the behaviour of const might change with each version of FPC as it's not part of the platform ABI, thus it might be that in some newer version it's decided to pass a parameter type in a more optimal way.
To me that means, the meaning of const is not fixed, there is no guarantee that const will behave in one version the same way it behaves in another. For me, that is more than enough not to use it.
As I understand, it means that what might change is how compiler makes decision whether to pass a const parameter -- by value or by reference.
What does not change is the fact which is clearly documented -- that it is not guaranteed how parameter will be passed and that you must not assume that it is passed by reference.
So, what can change is just implementation detail, nothing else.
This is how I understand what PascalDragon meant. I hope he will see this and clarify what he meant.
But you should understand well that the meaning of const has nothing to do about whether it is passed by reference or by value.
It shouldn't but, unfortunately it does. Sometimes "const" means a parameter passed by reference
Not in FPC. It only means that it is constant. How it is passed is implementation detail (as such, it can change in future, if you don't rely on it, you will never encounter bad surprises).
If by "sometimes", you mean Delphi vs FPC, then yes, here FPC and Delphi are different (which is also clearly documented).
Borland is responsible for muddying that water by associating semantics to const that have nothing to do with declaring a parameter is constant.
True, but here FPC developers decided not to follow Delphi blindly. So, in FPC const means that it is constant, nothing else. This will not change in future versions.
Unless for some reason you need to know whether it will be passed by value or by reference (and you would very rarely need to know it, why would you?)
There are quite a few times when you _really_ need to know. Here is an example, the buffer parameter of the WriteFile windows API is declared as "const buffer" (untyped). I was porting some C code to FPC, I pass the pointer to my buffer to WriteFile and I'm getting garbage out. I look at the code and it's perfectly fine, in full accordance with how WriteFile is documented. After a little bit of digging, I find that FPC is passing a pointer to my buffer pointer (pointer to pointer) instead of just the pointer to my buffer, that because of "const".
Then it is wrongly declared, it is wrong translation of win api header.
Where is it declared? If in FPC sources, this is a bug which should be reported.
If third party, then it might have been translated to be used with Delphi, and yes, we know that const parameter passing is not compatible with FPC.
With external routines we truly have to know how parameters are passed. So, yes, const parameters should be avoided in external declarations. There you have the point. Don't use it there.