[fpc-pascal] Untyped var params

Sven Barth pascaldragon at googlemail.com
Sun Jan 8 09:24:03 CET 2017


Am 08.01.2017 04:43 schrieb "Dmitry Boyarintsev" <skalogryz.lists at gmail.com
>:
>
> On Sat, Jan 7, 2017 at 6:02 PM, Lars <noreply at z505.com> wrote:
>>
>> Some brave soldiers once tried to reinvent generics using these tricks..
>
>
> Well, Pascal run-time has been using "hidden" generics forever.
>
> As an example:
> http://www.freepascal.org/docs-html/rtl/system/val.html
>
> Val() declares the second parameter as untyped var parameter.
> Unfortunately, it's not quite so. Compiler recognizes  the run-time
function and requires the parameter to be either an Integer or Float-point
type (or an enumerated type since 2.3.1).
>
> So it's more a generic-like behavior (with integer and float types
specialized)

Val() is a compiler intrinsic so there doesn't exist a declaration for it
anyway, so it's quite a bit outside of the scope of var parameters.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170108/c5d3ea6e/attachment.html>


More information about the fpc-pascal mailing list