Am So., 27. Jan. 2019, 02:53 hat John Doe <slightlyoutofph...@gmail.com>
geschrieben:

> However, I'm also quite simply unaware of any specific realistic scenario
> where I would *ever* specify a un-prefixed record in a method (in my own
> projects for example I actually haven't used anything but "var" and
> "constref" for years, not even just normal const as it doesn't always "do
> the trick" I've found), and I do think that on a more broad scope it is
> highly unlikely that most existing record methods written in an
> "unprefixed" fashion were done that way for any particular or intentional
> reason.
>

As I suggested in my answer one situation is interfacing with non-Pascal
code.
Also there is another side effect that at least needs to be kept in mind:
if you have multithreaded code having one of the by-ref parameter types
across thread boundaries and one thread changing a value (e.g. because it
was passed as "var" there and some other function works with "constref")
will result in the values all threads see to be changed.
This might be quite a constructed scenario, but we do explicitly warn in
the documentation of a similar situation. See the second remark here:
https://freepascal.org/docs-html/current/ref/refsu67.html#x179-20100014.4.4
(the first remark there is also somewhat important as "const" alone
provides no guarantee of being passed by-ref, only that the compiler won't
allow you to write assignments with the parameter or its fields on the left
side).

Regards,
Sven

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

Reply via email to