On 22/10/2010 12:28, Jonas Maebe wrote:

AFAIK "constref" was invented for passing values to external subroutines, that expect a reference. In how far does "constref" affect the *caller*, in contrast to e.g. "var"? Can constref pass properties, which are not allowed as var parameters?


Right now it's allowed (if the property uses a getter, the getter is called and its result is put into a temp location whose address is passed), but I think that's a bug in the implementation.

Why?

If constref *guarantees* a ref, then that sounds correct (Using a temp var).

IMHO the importance would be to make sure, that a property without a getter function, does also use a tempvar => so the behaviour does not change, if the property changes to use a getter.

Then again it could be argued, if the developer used constref, he promised not to touch the value, if he breaks that promise, and get's burned... (where is that mail about shoting yourself in the foot...)

Martin

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to