From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Design by contract and control inversion
Date: Wed, 07 Nov 2012 02:34:58 +0100
Date: 2012-11-07T02:34:58+01:00 [thread overview]
Message-ID: <op.wndqold9ule2fv@cardamome> (raw)
In-Reply-To: op.wm41x3yxule2fv@cardamome
Le Fri, 02 Nov 2012 09:59:53 +0100, Yannick Duchêne (Hibou57)
<yannick_duchene@yahoo.fr> a écrit:
> -- abc-sets-base.ads
>
> generic
>
> type Element_Type is private;
> type Cardinal_Type is (<>);
>
> package ABC.Sets.Base is
As it was posted, a note on this.
The `Cardinal_Type` is just a discrete type here, which may looks
over‑generalized to somebodies, and indeed the standard Ada containers use
a range type instead. The discrete type is enough even for a
implementation, but if you wish to add pre/post condition on the
cardinality in the specification, then a discrete type becomes a burden
(unless you enjoy Peano arithmetic a lot). There's no real rule here, that
just depends… Just still one thing: that's always OK to change from the
discrete type to a range type, but not the opposite; so that may be better
to start with the discrete type and change this later if required.
--
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University
next prev parent reply other threads:[~2012-11-07 1:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-31 19:28 Design by contract and control inversion Yannick Duchêne (Hibou57)
2012-11-01 17:13 ` Yannick Duchêne (Hibou57)
2012-11-01 20:29 ` Adam Beneschan
2012-11-02 3:40 ` Yannick Duchêne (Hibou57)
2012-11-02 8:59 ` Yannick Duchêne (Hibou57)
2012-11-02 12:32 ` Yannick Duchêne (Hibou57)
2012-11-07 1:34 ` Yannick Duchêne (Hibou57) [this message]
2012-11-02 16:45 ` Shark8
2012-11-07 1:51 ` Yannick Duchêne (Hibou57)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox