The first declaration

const
   sName : string = 'This is a test';

Declares a typed constant, which is really an initialized variable when
compiled in the default state {$J+}.  If you declare {$J-},  typed constants
behave like true constants, except that you can give them values of
records, arrays and pointers.  Don't know if it's the same with Delphi, but
in BP I think typed constants existed in the data segment.

Bob

----- Original Message -----
From: "John Christenhusz" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Monday, November 12, 2001 12:29 PM
Subject: [DUG]: Const


> Hi all,
>
> Can anybody tell me the difference between the following two declarations
> and why you want to use the first one. The second one seems to use less
> memory!
>
>
> const
>    sName : string = 'This is a test';
>
>
> and
>
> const
>    sName  = 'This is a test';
>
>
>
> TIA
>
> John.
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
>


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to