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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,86c750b8474bf6d5 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.germany.com!news.motzarella.org!motzarella.org!not-for-mail From: Sebastien Morand Newsgroups: comp.lang.ada Subject: Re: About String Date: Sun, 08 Jun 2008 19:03:17 +0000 Organization: A noiseless patient Spider Message-ID: <484C2CF5.6060309@gmail.com> References: <484ABED3.8040909@obry.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: feeder.motzarella.org U2FsdGVkX1/daIOwrYNn2v/1R2TVjpEhZBvcbSK2j7WmTlqlnn5vQSSQ4QbeaiHAS/608ZQWEzjj/9fggbhArC1CSvG0Ovfc9yEE2p487VXBDqQccf0L8vv21rrkArKzXkCoSIYxR7U= X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Sun, 8 Jun 2008 19:00:07 +0000 (UTC) In-Reply-To: X-Auth-Sender: U2FsdGVkX19AhPFJtiqIrFgPl8t3H1OTAysR9aoiYNg= Cancel-Lock: sha1:l+Xx3odhmSUP+YuDyXf2FPdFjY0= User-Agent: Thunderbird 2.0.0.12 (X11/20080406) Xref: g2news1.google.com comp.lang.ada:618 Date: 2008-06-08T19:03:17+00:00 List-Id: > I meant to say > > procedure Patati_Patata is > begin > begin > declare > S : String := A_Function_Raising_Constraint_Error; > begin > -- some code > end; > exception > when Constraint_Error => > -- deal with the problem .. > end; > -- .. and carry on > end; And it's what exactly I don't think pretty nice and easy to maintain. Other solution proposed by previous post is to separate the code with nested function: procedure Patati_Patata is function Manage_S return String; function Manage_S return String is begin declare S : String := A_Function_Raising_Constraint_Error; begin -- some code return S; end; exception when Constraint_Error => -- deal with the problem .. return ""; -- Or something else to manage the error but something must be returned to be consistent end; S: String := Manage_S; begin -- .. and carry on end; I think it's a better way especially because: 1) You can put away the nested function (for instance as a private package function) 2) You can reuse the function 3) You string are constant most of time (meaning: "S: constant String := Manage_S;") The only disadvantage for me is that you write a lot little function if you use a lot of string (and frankly, you always do in high level application). I wonder too if there is a nice way to manipulate string using access type. I don't choose to try this way because I think it's the better way to introduce some memory link. Sebastien