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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: [Newbie] doubly constrained array, dumb question Date: Mon, 26 Feb 2018 22:52:08 +0200 Organization: Tidorum Ltd Message-ID: References: <62f83fe5-15d6-41cf-952f-bc3cb077d42f@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net ii/mtG/XERhV5AZIjmgDAQtw9P8tngnEc2HEPwLLxA2YxuKiPB Cancel-Lock: sha1:Z7XVUEdTofE0m4f170Cp9wuH5+0= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: <62f83fe5-15d6-41cf-952f-bc3cb077d42f@googlegroups.com> Xref: reader02.eternal-september.org comp.lang.ada:50661 Date: 2018-02-26T22:52:08+02:00 List-Id: On 18-02-26 18:26 , Mehdi Saada wrote: > Hello. > > I would like an constrained String subtype with narrower bounds that Positive'Range. > How can I do something like: > subtype Possible_Length is NATURAL range 1..80; > subtype T_Line is String (Possible_Length range <>); > ? I know "range <>" isn't included in the definition of "range_constraint". How can I express the same thing. > So that I can get after, a dynamic string with: > A: access T_LINE := new T_LINE'("BLABLABLA"); while checking for its range. I think the closest you can come is to define your own string type such that it can be type-converted to/from String, for example like this: subtype Small_Positive is Positive range 1 .. 20; type Short_String is array (Small_Positive range <>) of Character; SS : constant Short_String := "abc"; S : constant String := String (SS); -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .