From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,54c513170bafd693 X-Google-Attributes: gid103376,public From: Gautier Subject: Re: Strings TP/Ada (was Desirability of C++) Date: 2000/05/02 Message-ID: <390EF94D.AE560CBD@maths.unine.ch>#1/1 X-Deja-AN: 618303874 Content-Transfer-Encoding: 7bit References: <390DEC7F.9429C82C@online.no> <8emhtk$pka4@ftp.kvaerner.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: 2 May 2000 17:50:38 +0100, mac13-32.unine.ch Organization: Maths - Uni =?iso-8859-1?Q?Neuch=E2tel?= MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-05-02T00:00:00+00:00 List-Id: Preben Randhol: > As I cannot remember much of turbopascal I curious: > If you write in turbopascal. > line : string[12]; > short_line : string[5]; > line := "Hello World!"; > short_line := line; > would short_line be "Hello" or will it be altered to a string[12] and > thus contain all of line? No - the variable is not extensible (string[5] reserves 6 bytes on stack). Will "Hello World!" be truncated or issue a range check error ? It may depend on the state of the range check switch ({$R+/-}), the version of TP, the fast library patches, and so on... In fact string[N] is a predefined unconstrained type in TP (and the only!), and corresponds to an array[0..N]. The 0th character contains the length. Some nice things: - String (without [N]) means String[255] - A very Borlandesque one: the {$V+/-} switch (strict var checking) alters the language semantic where it appears and until the next one! Also as command-line, or in tpc.cfg, or as a check in option panel... When it is "on", you can pass as "var" (by reference) only variables of the same subtype as specified; when "off", all variables of type String ! So, don't applause too early the whole "Borland string model"... In addition, you can program all that in Ada with unconstrained types, so it's not a so awful situation... _____________________________________________ Gautier -- http://members.xoom.com/gdemont/