comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: "functional" programming in Ada
Date: Tue, 6 Mar 2018 14:17:34 -0600
Date: 2018-03-06T14:17:34-06:00	[thread overview]
Message-ID: <p7mt0u$rqn$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: cd48925d-5cac-465c-96c3-a392f0ce4079@googlegroups.com

"Mehdi Saada" <00120260a@gmail.com> wrote in message 
news:cd48925d-5cac-465c-96c3-a392f0ce4079@googlegroups.com...
>> From a compiler writer POV I may understand it for the same reasons we
>> have the private part in the spec.
> How come ? Why should the compiler handle those functions differently
> than normal functions whose body is forbidden to be anywhere else than in 
> the package body ?

It helps other (non-Ada) tools; in particular proof and analysis tools, if 
the entire details of a precondition/postcondition are available to the 
tools (and without depending on contents of bodies). This literally led to 
preconditions that were many pages long. Expression functions were 
introduced in part to allow some abstraction in contracts without hiding the 
details of thosee contracts from the tools.

Secondarily, a compiler can take advantage of these for better inlining and 
better optimization of contracts. [The real reason I was interested.] They 
also open up some other possibilities (not all taken advantage of yet): 
user-defined static expressions; default implementation of functions for 
interfaces; anonymous functions to pass for one-time use parameters.

Generally, I'd expect them to appear mainly in private parts, because the 
visible spec shouldn't include enough info to be able to usefully implement 
much -- you usually need access to the components of the central private 
type in order to write such a function.

They *are* tempting to use, especially in quick-and-dirty code (like ACATS 
tests). I've found myself having to remove them from tests that are supposed 
to work on Ada 95 or Ada 2005.

                             Randy.



  parent reply	other threads:[~2018-03-06 20:17 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-06 11:34 "functional" programming in Ada Alejandro R. Mosteo
2018-03-06 13:09 ` Dmitry A. Kazakov
2018-03-06 14:35   ` Alejandro R. Mosteo
2018-03-06 15:08     ` Dmitry A. Kazakov
2018-03-06 16:00       ` Manuel Collado
2018-03-06 16:37         ` Dmitry A. Kazakov
2018-03-06 22:16           ` Manuel Collado
2018-03-07  8:41             ` Dmitry A. Kazakov
2018-03-07  4:46         ` Paul Rubin
2018-03-06 13:29 ` Mehdi Saada
2018-03-06 14:34   ` Alejandro R. Mosteo
2018-03-06 14:36     ` Mehdi Saada
2018-03-06 15:27       ` Alejandro R. Mosteo
2018-03-06 16:26       ` Jeffrey R. Carter
2018-03-06 20:17       ` Randy Brukardt [this message]
2018-03-07 14:30         ` Alejandro R. Mosteo
2018-03-06 15:01 ` Dan'l Miller
2018-03-06 15:25   ` Alejandro R. Mosteo
2018-03-07 10:07 ` Maciej Sobczak
2018-03-07 10:52   ` Mehdi Saada
2018-03-07 13:11     ` Pascal Obry
2018-03-07 13:53       ` Dmitry A. Kazakov
2018-03-07 16:13       ` Dan'l Miller
2018-03-12  0:13         ` Robert I. Eachus
2018-03-08  3:34       ` Randy Brukardt
2018-03-08  8:23         ` Dmitry A. Kazakov
2018-03-08 22:49           ` G. B.
2018-03-09  8:38             ` Dmitry A. Kazakov
2018-03-09  8:40           ` Simon Wright
2018-03-09 13:39             ` Dmitry A. Kazakov
2018-03-07 15:03   ` Alejandro R. Mosteo
2018-03-07 15:16     ` Alejandro R. Mosteo
2018-03-07 20:34     ` Robert A Duff
2018-03-07 22:47     ` Jeffrey R. Carter
2018-03-08  0:26     ` Shark8
2018-03-08  0:45     ` Paul Rubin
2018-03-08 11:07       ` Alejandro R. Mosteo
2018-03-08 18:24 ` G. B.
2018-03-09 14:41   ` Alejandro R. Mosteo
replies disabled

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