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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2a3157e5254b8223 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: Array slices and types Date: Wed, 20 Aug 2008 19:47:35 +0200 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <5886ab95-8744-4b72-b911-e4cb8889c7e7@d1g2000hsg.googlegroups.com> Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: tigger.scc.uni-weimar.de 1219250113 10635 141.54.178.228 (20 Aug 2008 16:35:13 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Wed, 20 Aug 2008 16:35:13 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: <5886ab95-8744-4b72-b911-e4cb8889c7e7@d1g2000hsg.googlegroups.com> Xref: g2news1.google.com comp.lang.ada:1687 Date: 2008-08-20T19:47:35+02:00 List-Id: On Wed, 20 Aug 2008, Maciej Sobczak wrote: > Consider this: > > type Name is new String (1 .. 10); > > N : Name; > > Some_String : String := "abc"; > > How can I assign Some_String to the beginning slice (ie. to the first > three characters) of N? Some_String does always contain exactly ten characters, no more, no less. But you can assign the first three characters of Some_String to name: N(1 .. 3) := Some_String; > Everything that I can think of (short of copying characters > individually) hits the type compatibility problem. Here is a completely compilable example: with Ada.Text_IO; procedure Slice is S: String(1 .. 3); T: String(1 .. 5) := (others => '*'); U: String(1 .. 9) := (others => '-'); begin S := T(1 .. 3); U(1 .. 5) := T; Ada.Text_IO.Put_Line(S & "|" & T & "|" & U); end Slice; As expected, the output is a line with the string "***|*****|*****----". -- ------ Stefan Lucks -- Bauhaus-University Weimar -- Germany ------ Stefan dot Lucks at uni minus weimar dot de ------ I love the taste of Cryptanalysis in the morning! ------