comp.lang.ada
 help / color / mirror / Atom feed
From: "Corey Ashford" <corSPAMey@rational.com>
Subject: Re: STATIC Variables
Date: 1998/07/23
Date: 1998-07-23T00:00:00+00:00	[thread overview]
Message-ID: <6p6s84$klg$1@usenet.rational.com> (raw)
In-Reply-To: 35B6EC76.ED3B1493@infaut.et.uni-magdeburg.de


Marc Enzmann wrote in message <35B6EC76.ED3B1493@infaut.et.uni-magdeburg.de>...
>Does Ada have an equivalent to C's STATIC declaration ?
>I've found this to be very helpful in some signal-processing
>and simulation algorithms.
>I've thumbed through a number of Ada textbooks but didn't find
>anything.
>Any hints ?
>
>Thanks,
>
>Marc
>--

You might want to use www.dejanews.com to look through past responses
to this question.

The standard answer is usually to wrap a package around the function,
and place the static variable within the package.  This slightly
complicates calling the function, but you could use a library level
wrapper function to make the package invisible.

e.g.

package foo is
   function bar (x:integer) return integer;
end foo;

package body foo is

   var : integer;

   function bar (x:integer) return integer is
   begin
      var := var + 1;
      ...
      return factorial(var) * x;
   end bar;

end foo;


function wrapped_bar (x: integer) return integer is
begin
    return foo.bar(x);
end wrapped_bar;


- Corey






  reply	other threads:[~1998-07-23  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-07-23  0:00 STATIC Variables Marc Enzmann
1998-07-23  0:00 ` Corey Ashford [this message]
1998-07-23  0:00 ` Robert Dewar
replies disabled

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