comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Ada 2012 Corrigendum
Date: Fri, 12 Sep 2014 15:08:27 -0400
Date: 2014-09-12T15:08:27-04:00	[thread overview]
Message-ID: <wcciokszmfo.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: kFGQv.205472$O13.15633@fx17.iad

Shark8 <OneWingedShark@gmail.com> writes:

> Issue 2:	Static (and compile-time) Functions
>
> !topic		Compile-time Executed Functions
> !reference	None [?]

Reference the section on static expressions, and possibly the
expression-functions section.

> !from		Edward Fish, 12 Sep 14
> !keywords	Compile-time Static Pure Functions Macro
>
> Given the advent of expression-functions, and the loosening of
> 'Function' from the more mathematical concept [that is, allowing IN OUT
> parameters] it makes some sense to introduce an aspect [or set of
> aspects] that re-introduces [and strengthens] the guarantees that were
> implicit (or initially intended) in the language.

Well, Ada functions have never been pure mathematical functions.
They've always been allowed to read and write global variables,
heap data, etc.

You make a good argument that this suggestion would be useful,
but without actual RM wording, it's impossible to know exactly
what you are proposing.  For example, is this aspect allowed
only on expression functions?  If it's allowed on functions
with regular old bodies, what happens if the body contains
machine-code inserts?  If it's only allowed on expression
functions, then why do you need an aspect? -- you could just
say a call to an expression function is a static expression
if the function and its actual parameters have certain properties.
In fact, I think that idea was discussed when expression functions were
invented -- you might find it useful to read the AI that introduced
expression functions.

There must be some restrictions on what can go in these functions
(e.g. calls to other impure functions?).

What happens if you call one of these things with nonstatic actual
parameters?  I'd guess that should be legal, but that call won't
itself be a static expression.

Are these things allowed to have parameters/results of access type?
Composite type?

> Function MSB (N : Integer) Return Integer
> with PRE_COMPILE -- or STATIC, or PURE_FUNCTION, or whatever

I don't like "Pre_Compile" -- it seems too mechanistic.
Why not "Pure"?  "Pure_Function" already exists in GNAT,
and it means something different, so we wouldn't want to
use that name.

All in all, I suspect that this is too big of a change for the benefit.
It's not a bad idea, though, in the abstract.

- Bob


  parent reply	other threads:[~2014-09-12 19:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-12  3:26 Ada 2012 Corrigendum Shark8
2014-09-12 11:45 ` Peter Chapin
2014-09-12 12:48 ` Dmitry A. Kazakov
2014-09-12 19:09 ` Shark8
2014-09-12 18:51   ` Robert A Duff
2014-09-12 19:08   ` Robert A Duff [this message]
2014-10-04  0:32     ` 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