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.9 required=5.0 tests=BAYES_00 autolearn=ham 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!news.glorb.com!feeder.erje.net!news-fra1.dfn.de!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!uio.no!fi.sn.net!newsfeed1.fi.sn.net!news.song.fi!not-for-mail Date: Wed, 20 Aug 2008 21:52:26 +0300 From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Array slices and types References: <5886ab95-8744-4b72-b911-e4cb8889c7e7@d1g2000hsg.googlegroups.com> <1k5uib98w8fgw.bno6vggps1p3.dlg@40tude.net> In-Reply-To: <1k5uib98w8fgw.bno6vggps1p3.dlg@40tude.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <48ac6750$0$23587$4f793bc4@news.tdc.fi> Organization: TDC Internet Services NNTP-Posting-Host: laku61.adsl.netsonic.fi X-Trace: 1219258193 news.tdc.fi 23587 81.17.205.61:32955 X-Complaints-To: abuse@tdcnet.fi Xref: g2news1.google.com comp.lang.ada:1689 Date: 2008-08-20T21:52:26+03:00 List-Id: Dmitry A. Kazakov wrote: > On Wed, 20 Aug 2008 07:51:02 -0700 (PDT), 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? >>Everything that I can think of (short of copying characters >>individually) hits the type compatibility problem. > > > You need an unconstrained base type for this. In your case the base is > anonymous. So name it: > > type Name_Base is new String; -- The base type is now named > subtype Name is Name_Base (1..10); > N : Name; > Some_String : String := "abc"; > begin > N (1..3) := Name_Base (Some_String); Or you can use the 'Base attribute: N(1..3) := Name'Base (Some_String(1..3)); -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .