comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: "functional" programming in Ada
Date: Fri, 9 Mar 2018 14:39:26 +0100
Date: 2018-03-09T14:39:26+01:00	[thread overview]
Message-ID: <p7u2qe$1ppl$1@gioia.aioe.org> (raw)
In-Reply-To: lytvtphcbd.fsf@pushface.org

On 09/03/2018 09:40, Simon Wright wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>> On 08/03/2018 04:34, Randy Brukardt wrote:
> [...]
>>> The various contracts (preconditions, postconditions, predicates,
>>> etc.) all contain some executable code, and it is necessary for
>>> callers to be able to understand those contracts. Expression
>>> functions help in this, while the bulk of the implementation should
>>> remain in the body.
>>
>> These are not contracts if have any executable code, and more
>> importantly, understanding cannot be achieved by exposing
>> implementation/code.
>>
>> P.S. Contracts exist prior the program (programs, actuall) and surely
>> prior to any execution of (any implementation of any programs under
>> the contract).
> 
> When I was taught VDM (a long time ago, and never put to actual project
> use) we wrote what are essentially contracts. You'd be left to implement
> the corresponding code following the contracts.
> 
> Pre/postconditions etc correspond to these contracts, in a potentially
> executable form, and I'm going to call them contracts as a convenient
> shorthand (as in the Rationale).

Proper pre/post conditions are propositions to be used ("executed") in 
the logical inference/proof. They define the contract.

If an expression is used to define a contract, that contract is 
obviously undefined until the expression evaluated.

> As you know, the meaning of the program mustn't depend on actually
> executing the contracts, and the default GNAT behaviour is not to
> generate executable code for them (I don't know whether expression
> functions which are only involved in contracts actually generate object
> code, but one would hope they'd be eliminated by compiler analysis).

And if not?

> An expression function in the spec has to help in understanding what the
> contract says. I wondered whether it might correspond to a lemma? ("a
> subsidiary proposition , proved for use in the proof of another
> proposition").

There are propositions, theorems, lemmas. And there are algorithms, 
instructions etc. The former are never the latter and conversely. 
Expression-function can be either. That depends on the language we are 
talking about: #1 an expression of the meta-language of contracts or #2 
an expression of the object language Ada.

Now the point is that even if an expression-function were a part of the 
language of contracts, then that is still bad idea because the language 
design principles should hold for both languages. If the meta language 
of contracts becomes so complex that it would require procedural 
decomposition, then that must be done in a sane way, with separating 
interfaces and implementations. The contract-function would have bodies 
defined elsewhere rather than clumped together with specification.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2018-03-09 13:39 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
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 [this message]
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