<p>Am 15.04.2016 11:22 schrieb "Dennis" <<a href="mailto:dec12@avidsoft.com.hk">dec12@avidsoft.com.hk</a>>:<br>
><br>
><br>
>> > You could describe it as typecast done in the var clause of a method. The right hand identifier is not restricted to function parameters.<br>
>><br>
>> While it works using "absolute" for a public API is rather unsafe (I'd only use that in private methods). In those cases the "as" operator should he used (or at least "is" plus returning an error).<br>
>><br>
>> Regards,<br>
>> Sven<br>
>><br>
>><br>
> May I know why it is unsafe to use absolute on public method's parameters?</p>
<p>I didn't mean that in the context of the "public" section of classes, but if your API is available to third party users (that can also include other members of the same development team) then you need to make sure that the instance that is passed in is indeed a correct one as otherwise you'd access the wrong fields or methods. For this kind of mistake public and protected methods are of course the most affected ones as are routines that are declared in the interface section of a unit.</p>
<p>> Also, will there be any compiler options in which the parameters are passed through registers? In that case, will the absolute of private method's parameters still work?</p>
<p>Parameters are already often passed in registers (of course this depends on the platform). However parameters also often have a spilling locations in the stack to store the parameter if register pressure gets too high, so absolute shouldn't be a problem normally. It might also be that the usage of absolute prohibits some optimizations the compiler would otherwise do with that parameter inside the function.</p>
<p>Regards,<br>
Sven</p>