Santiago A. wrote on Wed, 16 Dec 2015:
In functions blockread and blockwrite, the result parameter is "var". And in blockread buffer is also "var". Couldn't they be marked as "out" instead of "var"?.
The result parameters can be changed. The BlockRead buffer parameter cannot be changed for the same reason that the parameters of fillchar and move cannot be changed: it changes the behaviour in case a managed type, or e.g. a record or array containing managed types, it passed. With "var", nothing special happens, while with "out", they are first finalised. If they are not yet initialised at that point (e.g. because they are the result of a plain getmem), this would introduce crashes.
Even though you cannot just blockread/blockwrite managed types anyway (since they are pointers), this can currently work if you ensure that all read/written managed types are nil. It may seem unlikely, but at least changing the "var" parameters of move/fillchar to "out" even caused crashes in the compiler because the RTL relies on the current behaviour (and using move/fillchar with managed types is not very common/recommended either in the general case).
Jonas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal