comp.lang.ada
 help / color / mirror / Atom feed
From: mcsun!uknet!keele!csa09@uunet.uu.net  (P. Singleton)
Subject: Re: how pure are functions?
Date: 9 Apr 92 14:20:11 GMT	[thread overview]
Message-ID: <2510@keele.keele.ac.uk> (raw)

>From article <18363@ector.cs.purdue.edu>, by young@cs.purdue.EDU (Michal Young
):

> Mark Biggar says: 

>> More then likely that variable is only visible in the body of the package
>> that defines the function and so is invisible to the user of the function,
>> but strictly the function itself has no "internal" state. 
 
> This is true, strictly speaking, but from the viewpoint of a user,
> verifier, or compiler, Ada functions do not appear to be stateless.
> For instance, one cannot generally substitute 2*f(x) for f(x) + f(x).

Yes, that nicely exemplifies what I meant by "referential transparency",
which was: that the value of a function is determined *only* by its
arguments, and not by the history of execution, and so the compiler can
symbolically manipulate the program (e.g. transform it for efficiency, or
otherwise partially evaluate it, or reason about its correctness, etc.).
Also it should be free from side-effects (as well as the aforementioned
side-infects).

> There are good practical reasons for not insisting that every
> "function" be a pure function, but it would be quite helpful if the
> language provided some way to indicate that certain "functions" were
> actually functions in the mathematical sense.

Yes, I hoped that the distinction of "functions" from the honestly-named
"value-returning procedures", but I am told that this distinction is
obsolete.
----
  __   __    Paul Singleton (Mr)           JANET: paul@uk.ac.keele.cs
 |__) (__    Computer Science Dept.        other: paul@cs.keele.ac.uk
 |  .  __).  Keele University, Newcastle,    tel: +44 (0)782 621111 x7355
             Staffs ST5 5BG, ENGLAND         fax: +44 (0)782 713082

             reply	other threads:[~1992-04-09 14:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-04-09 14:20 P. Singleton [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-04-07 19:05 how pure are functions? Michal Young
1992-04-07 17:13 Mark A Biggar
replies disabled

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