comp.lang.ada
 help / color / mirror / Atom feed
From: Marius Amado Alves <amado.alves@netcabo.pt>
Cc: comp.lang.ada@ada-france.org
Subject: Re: advice on package design
Date: Thu, 17 Mar 2005 21:14:30 +0000
Date: 2005-03-17T21:14:30+00:00	[thread overview]
Message-ID: <mailman.39.1111094092.23655.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <wccwts66lh4.fsf@shell01.TheWorld.com>

>> with Ada.Text_IO; use Ada.Text_IO;
>> procedure Main is
>>     function Foo (I : Integer) return Integer is
>>        I2 : Integer := I + 1;
>>     begin
>>        return I2;
>>     exception
>>        when others =>
>>           return 0;
>>     end Foo;
...
>> exception
>>     when others =>
>>        Put_Line ("Rats... why not catch it in 'Foo'?");
>>

Bob told you why. I'll tell you how, just in case. Rewrite Foo thus:

  function Foo (I : Integer) return Integer is
  begin
     declare
        I2 : Integer := I + 1;
     begin
        return I2;
     end;
  exception
     when others =>
        return 0;
  end Foo;

(Of course this how follows from the why. I2 is no longer visible in 
the handler.)




  reply	other threads:[~2005-03-17 21:14 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-07 16:23 advice on package design spambox
2005-03-07 21:08 ` Dmitry A. Kazakov
2005-03-08 12:48   ` spambox
2005-03-08 17:18     ` Dmitry A. Kazakov
2005-03-12 19:57   ` Robert A Duff
2005-03-12 20:45     ` Dmitry A. Kazakov
2005-03-12 21:59       ` Robert A Duff
2005-03-13  9:23         ` Dmitry A. Kazakov
2005-03-16 20:41           ` Robert A Duff
2005-03-17 10:22             ` Dmitry A. Kazakov
2005-03-17 14:04               ` Robert A Duff
2005-03-17 15:59                 ` Dmitry A. Kazakov
2005-03-17 19:10                   ` Robert A Duff
2005-03-17 19:47                     ` Martin Dowie
2005-03-17 20:55                       ` Robert A Duff
2005-03-17 21:14                         ` Marius Amado Alves [this message]
2005-03-18  9:31                           ` Martin Dowie
2005-03-18  9:38                         ` Martin Dowie
2005-03-21 16:19                           ` Robert A Duff
2005-03-17 20:48                     ` Dmitry A. Kazakov
2005-03-17 21:26                       ` Robert A Duff
2005-03-18  3:06                         ` Jared
2005-03-18 10:00                         ` Dmitry A. Kazakov
2005-03-21 16:17                           ` Robert A Duff
2005-03-21 18:16                             ` Dmitry A. Kazakov
2005-03-21 20:35                               ` Robert A Duff
2005-03-22 10:55                                 ` Dmitry A. Kazakov
2005-03-17 23:23                 ` Randy Brukardt
replies disabled

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