home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,452 of 2,978   
   Jason Burgon to All   
   Re: VB 2 pascal byrev=var byval not   
   05 Mar 05 23:28:24   
   
   From: gvision@ntlworld.com   
      
   I wrote,   
      
   > Value modifiication checks of "const" paramters are performed at   
   > compile-time it does not therefore generate any extra code. The compiler   
   > will however optimise "const" parameters for size, so that strings,   
   records   
   > and anything that isn't a Real or hasn't got a size of 1, 2 or 4 bytes   
   will   
   > actually be passed by reference; ie as a pointer, and ~this~ feature will   
   > ironically cause more code to generated if the parameter is accessed more   
   > than in one place in the function.   
      
   Having thought about this a little more, the situation is as little more   
   subtle than the above when it comes to code size and complex-type (strings,   
   records, object etc) const parameters:   
      
   If the function only ever references the const parameter in its entirety,   
   such as:   
      
   procedure DoSomething(const S: String);   
   var   
     W: String;   
   begin   
     W := Copy(S, 1, 8);   
     ...   
   end;   
      
   Then no extra code (compared to a normal parameter) is generated. However,   
   if the function references sub-components of the const parameter (eg: S[x]   
   in the case of string, or a the field of a record, other than the first   
   field of the record), then nore machine code is required to obtain its   
   address, and more code will therefore be generated.   
      
   --   
   Jay   
      
   Author of Graphic Vision   
   http://homepage.ntlworld.com/gvision/   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca