comp.lang.ada
 help / color / mirror / Atom feed
From: Sebastien Morand <seb.morand@gmail.com>
Subject: Re: About String
Date: Sun, 08 Jun 2008 19:03:17 +0000
Date: 2008-06-08T19:03:17+00:00	[thread overview]
Message-ID: <484C2CF5.6060309@gmail.com> (raw)
In-Reply-To: 

> 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



      reply	other threads:[~2008-06-08 19:03 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-06 17:29 About String Sébastien Morand
2008-06-07 16:18 ` Simon Wright
2008-06-07 17:01   ` Pascal Obry
2008-06-07 22:13     ` Chris Moore
2008-06-08  6:47       ` Niklas Holsti
2008-06-08  7:35         ` Dmitry A. Kazakov
2008-06-08 10:29           ` Sebastien Morand
2008-06-08 10:53             ` Dmitry A. Kazakov
2008-06-08 11:14           ` Niklas Holsti
2008-06-08 13:16             ` Dmitry A. Kazakov
2008-06-08 17:17               ` Niklas Holsti
2008-06-09  7:26                 ` Dmitry A. Kazakov
2008-06-08 11:48           ` Martin
2008-06-08 13:17             ` Conditional declarations (was: About String) Dmitry A. Kazakov
2008-06-08 18:26           ` About String Chris Moore
2008-06-08 18:32         ` Robert A Duff
2008-06-08 20:51           ` Maciej Sobczak
2008-06-08 21:19             ` Robert A Duff
2008-06-09  7:14               ` Dmitry A. Kazakov
2008-06-09  9:43                 ` Georg Bauhaus
2008-06-09 10:25                   ` Dmitry A. Kazakov
2008-06-09 10:42                     ` Sébastien Morand
2008-06-09 11:43                     ` Georg Bauhaus
2008-06-09 12:03                       ` Dmitry A. Kazakov
2008-06-15 19:38                 ` Robert A Duff
2008-06-15 20:52                   ` Dmitry A. Kazakov
2008-06-15 22:06                     ` Robert A Duff
2008-06-16  8:31                       ` Dmitry A. Kazakov
2008-06-16 19:17                         ` Robert A Duff
2008-06-16 20:30                           ` Dmitry A. Kazakov
2008-06-16 22:02                           ` Georg Bauhaus
2008-06-16 23:04                             ` Robert A Duff
2008-06-09 11:00               ` Georg Bauhaus
2008-06-09 14:27                 ` Britt Snodgrass
2008-06-15 19:50                   ` Robert A Duff
2008-06-15 19:48                 ` Robert A Duff
2008-06-08 11:13     ` Simon Wright
2008-06-08 19:03       ` Sebastien Morand [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox