about IOResult function lazarus / 61-Beginners ---------------------------------------------------------------------- Lulu · 2023-07-14 13:50 Hi, playing with IOResult function, I've looked at its code (in system.inc): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Function IOResult:Word;var  HInoutRes : PWord;Begin  HInoutRes:=@InoutRes;  IOResult:=HInOutRes^;  HInOutRes^:=0;End; What is the purpose of using the intermediate variable HInoutRes to access the content of InoutRes ? Why the code is not simple as: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Function IOResult:Word;Begin  IOResult:=InoutRes;  InoutRes:=0;End;? Thanks ---------------------------------------------------------------------- marcov · 2023-07-14 14:33 Afaik in inoutres is a threadvar, and this only calls to get  the address of the threadvar once, rather than twice (read+write). ---------------------------------------------------------------------- Kays · 2023-07-14 14:39 Quote from: marcov on July 14, 2023, 04:33:10 pmAfaik in inoutres is a threadvar, and this only calls to get  the address of the threadvar once, rather than twice (read+write).Compare commit CD358045. ---------------------------------------------------------------------- Lulu · 2023-07-14 15:25 Marcov, Kays, thanks you for your reply. i was not aware about threadvar. I read https://www.freepascal.org/docs-html/ref/refse26.html Quote from: marcov on July 14, 2023, 04:33:10 pmAfaik in inoutres is a threadvar, and this only calls to get  the address of the threadvar once, rather than twice (read+write). I assume it's to speed up the operation because accessing threadvar is slower than normal var? ---------------------------------------------------------------------- 440bx · 2023-07-14 15:53 Quote from: Lulu on July 14, 2023, 05:25:18 pmI assume it's to speed up the operation because accessing threadvar is slower than normal var? Correct!. ---------------------------------------------------------------------- Lulu · 2023-07-16 08:16 thank you all for the clarifications