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 2,136 of 2,978   
   Dr John Stockton to All   
   Re: printing variable problems   
   13 Apr 06 21:08:24   
   
   From: jrs@merlyn.demon.co.uk   
      
   JRS:  In article <1144937299.399996.222810@e56g2000cwe.googlegroups.com>   
   , dated Thu, 13 Apr 2006 07:08:19 remote, seen in   
   news:comp.lang.pascal.borland, dik  posted :   
   >since i see it here, i have never understood the advantage of or the   
   >reason for:   
   >   
   >   function SL(const S : string ; const L : byte) : string ;   
   >   
   >vs:   
   >   
   >   function SL(S : string ; L : byte) : string ;   
      
   With "const" the compiler will allow no code that may change the values   
   of the parameters, and the same storage is used internally & externally.   
      
   With "var" instead of "const", the same storage is used internally &   
   externally, so the external value can be changed.   
      
   With neither (for which there *should* be a reserved word), the internal   
   variable is a changeable copy of the external, which is safely   
   unchanged.   
      
   Optimisation may change those, but must preserve their appearance.   
      
      
      
   Defining   procedure X(var A : integer ; const B : integer) ;   
   and calling as   X(C, C) ;   means that if X changes A, B will change.   
      
      
   See in   .   
      
   --   
    © John Stockton, Surrey, UK.  ?@merlyn.demon.co.uk   Turnpike v4.00   MIME. ©   
      TP/BP/Delphi/&c., FAQqy topics & links;   
        RAH Prins : c.l.p.b mFAQ;   
      Timo Salmi's Turbo Pascal FAQ.   
      
   --- 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