comp.lang.ada
 help / color / mirror / Atom feed
From: steve.folly@rdel.NOT-A-REAL.co.uk (Steve Folly)
Subject: Re: Ada 0x Wish List
Date: Mon, 12 Feb 2001 13:18:35 GMT
Date: 2001-02-12T13:18:33+00:00	[thread overview]
Message-ID: <3a87e143.185542375@news.rrds.co.uk> (raw)
In-Reply-To: 87u260bba1.fsf@deneb.enyo.de

On 12 Feb 2001 08:39:18 +0100, Florian Weimer <fw@deneb.enyo.de>
wrote:

>"Peter Richtmyer" <pmr@efortress.com> writes:
>
>> 2) In a subroutine, would like to be able to declare variables that
>> are "persistent", like C "static" variables and only used by the one
>> subroutine.
>
>This feature wouldn't interoperate with tasking, so I think it's a bad
>idea.
>

But neither do global variables if you're not careful.  Just because
it's dangerous *if* you're using tasking, doesn't mean you should
prohibit it in the language. The LRM describes several areas
where doing things like that things will make a program erroneous.


There is a way to accomplish static/persistent variables in Ada...

Where, for example, you would want...

function Count return Natural is
   C : static Natural := 0;
begin
  C := C + 1;
  return C;
end;

Can be achieved ....

package Count_Package is 
   function Count return Natural;
end Count_Package

package body Count_Package is
   C : Natural := 0;
   function Count return Natural is
   begin
    C := C + 1;
    return C;
   end;
end Count_Package;

function Count return Natural renames Count_Package.Count;


-- 
SF.   



  reply	other threads:[~2001-02-12 13:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-12  3:25 Ada 0x Wish List Peter Richtmyer
2001-02-12  4:22 ` Jeffrey Carter
2001-02-12  7:23   ` Dale Stanbrough
2001-02-12 13:04     ` Preben Randhol
2001-02-13 16:33     ` Robert Deininger
2001-02-13 18:15       ` Keith Thompson
2001-02-12  7:39 ` Florian Weimer
2001-02-12 13:18   ` Steve Folly [this message]
2001-02-12 15:25   ` Arthur Schwarz
2001-02-12 14:29 ` John English
2001-02-13  8:31   ` Dr Adrian Wrigley
2001-02-13 20:46   ` Fraser Wilson
2001-02-13 22:06     ` Larry Hazel
2001-02-13 22:45       ` Fraser Wilson
2001-02-13 23:14         ` Larry Hazel
2001-02-13 23:59           ` David C. Hoos, Sr.
2001-02-14  1:22             ` Larry Hazel
2001-02-13 23:51     ` Keith Thompson
2001-02-14 11:23     ` David C. Hoos, Sr.
2001-02-15 22:01       ` Georg Bauhaus
2001-02-15 22:14         ` Marin David Condic
2001-02-17  8:43     ` Dr Adrian Wrigley
2001-02-12 16:08 ` Steve Folly
2001-02-12 17:53   ` Lao Xiao Hai
2001-02-12 18:22 ` (null)
  -- strict thread matches above, loose matches on Subject: below --
2001-02-15  1:33 Beard, Frank
replies disabled

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