comp.lang.ada
 help / color / mirror / Atom feed
* Pure function aspect?...
@ 2012-01-12 10:44 Martin
  2012-01-13  0:00 ` Randy Brukardt
  0 siblings, 1 reply; 11+ messages in thread
From: Martin @ 2012-01-12 10:44 UTC (permalink / raw)


Now Ada has bitten the bullet and allowed "in out" mode parameters in
functions, is it time to allow users to contract the other extreme and
allow a function to be declared Pure (no state changes, not even
hidden ones)? e.g.

package P is
   type T is tagged private;
   function Pure_F   (Self : T) return Integer
      with Pure;
   function Impure_F (Self : T) return Integer;
private
   type T is tagged record
      I : Integer := 0;
   end record;
end P;


Functions with a Pure contract would be allowed to call other
functions with pure contracts, read values/parameters but promise to
change nothing (not even via 'tricks' a la random number generator!!).

-- Martin



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-01-19 10:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-12 10:44 Pure function aspect? Martin
2012-01-13  0:00 ` Randy Brukardt
2012-01-13  8:45   ` Dmitry A. Kazakov
2012-01-13 11:01     ` Martin
2012-01-13 17:12       ` Dmitry A. Kazakov
2012-01-13 10:48   ` stefan-lucks
2012-01-14  0:00     ` Randy Brukardt
2012-01-16 10:48       ` Martin
2012-01-19  1:17         ` Randy Brukardt
2012-01-19 10:09           ` Dmitry A. Kazakov
2012-01-13 10:55   ` Martin

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