[fpc-devel] FPC_HAS_CONSTREF

Martin fpc at mfriebe.de
Fri Oct 22 15:09:58 CEST 2010


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




More information about the fpc-devel mailing list