comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Ada 2012 Constraints (WRT an Ada IR)
Date: Wed, 30 Nov 2016 16:58:58 -0800 (PST)
Date: 2016-11-30T16:58:58-08:00	[thread overview]
Message-ID: <3ef819e8-55f7-4ef7-9f37-77e6abc33f98@googlegroups.com> (raw)
In-Reply-To: <o1ndod$14ke$1@gioia.aioe.org>

On Wednesday, November 30, 2016 at 1:45:04 PM UTC-7, Dmitry A. Kazakov wrote:
> On 2016-11-30 19:28, Shark8 wrote:
> 
> > So, with that in mind it makes sense to
> > consider the usefulness of making Semantic_Analysis_Result its own
> > formal language: the Intermediate Representation.
> 
> It would be difficult without making intermediate effectively target 
> language, e.g. byte code. What you have in mind is some sort of data 
> definition language [DDL] (operations' semantics stripped).

In the sense that a program *IS* data, it certainly is a DDL.

> > These properties are ideal for many applications -- one of the most
> > practical to addressing some of the complaints/difficulties leveled at
> > Ada (like a poor ecosystem) would be implementation of a CPAN-style
> > repository... but far better -- for if we can, say, make this IR amiable
> > to storage in a DB (with attendant consistency-checks) we can eliminate
> > the storage of invalid Ada in said repository; furthermore, because we
> > have all the semantic-information already we could build-in tools to
> > allow correct dependency-storage, like Gnoga using Simple Components,
> > but with proper versioning so that a breaking change in a new version's
> > API could be detected and the older one with the required properties
> > could be retrieved.
> 
> Surely some level of introspection would be extremely helpful for 
> distributed and persistency systems.

This is true, but I don't think that ought to be the concern of the IR. -- Insofar as a CPAN-like tool is concerned w/ the IR the major operations are merely STORE and RETRIEVE; other functionality such as, say, tracking licenses or searching/indexing stored data don't involve the IR... in fact, the only operations that would are listing the dependencies and the aforementioned version-control.

Maybe a tool [or language for] operating on the IR would be appropriate, perhaps using generic/template functionality to enable the expression of a "compressed" form so that (e.g.) [[Wide_[Wide_]]String could all share common portions and so that you could have something operating across the interfaces of packages, generic or not, meta-programming stuff... but that seems pretty far outside the scope of creating an IR.

> Versioning is a huge issue unresolved. I am afraid that type 
> representation if not enough by far, because you need a lot of 
> additional information to decide substitutablity, which is key to 
> handling type versions.

This is true, a full "bullet-proof system" would require extensive unit-tests tightly coupled with the particular program/library... perhaps more than are comfortable/practical for the hobbyist and small-business types.

Requiring that level of support would be nice, from an end-user point-of-view, and certainly has appeal to me given my admiration of provability and desires for "the industry" to embrace better practices... but that would require *MUCH* more work, and hamper ease-of-use [to the point of hampering usability itself, I suspect] on the program/library uploader.

As much as I like "completely correct", versioning at the CPAN-like-repository level should probably be restricted to the public interface. (Essentially the analog of "can it compile?" asked of a prolog program with the sets of modules involved, starting with the most-recent versions and backtracking until the solution is found.)

> >>>>> No, I really don't.
> >>>>> I'm not talking about Ada-syntax,
> >>>>
> >>>> Yes you do, covariance vs. contravariance is semantics, not syntax.
> >>>
> >>> Maybe I'm misunderstanding.
> >>> I simply don't see how covariance vs. contravariance is at all
> >>> germane  to representing the definition of a type.
> >>
> >> It is relevant to the difference between Ada 83 style constrained types
> >> and constrained types introduced by predicates. Ada 83 constraints are
> >> more consistent because they took into account operations that must be
> >> covariant. E.g. adding to the list of examples:
> >>
> >>     subtype Text is String (1..80);
> >>
> >> That overrides 'First, 'Last, 'Range, 'Length and propagates the
> >> constraint to other types by promoting Text definite. None of this
> >> happens if you add a predicate because all operations are inherited
> >> as-is = contravariant.
> >
> > And shouldn't that (eg Predicated_Subtype'Pred or 'Last, etc) be
> > caught by the semantic-analysis phase? If so, then it's entirely a moot
> > point, isn't it?
> 
> The compiler cannot read minds. The information that the semantics of 
> 'Pred must be changed (and thus the operation becomes covariant) is 
> nowhere to get.

Of course it is, it's in the set of operations available to the subtype... imagine extending the ability to add constraints to values, but with operations. It is, in a very general sense, the same thing -- the values a type has are a set, the operations a type has are a set: if we can exclude items from the value-set, why can't we exclude operations from the operation-set?

> In the model of tagged types covariance is the default. 
> In the model of added predicates it is contravariance the default. 
> Ada-83 subtypes mix contravariance and covariance by hardwired rules.

Then wouldn't a way to represent both be applicable to representing an Ada-83 type?

> > But it certainly doesn't invalidate the concept of considering a
> > type  [and subtype] as the collection of a set of values and a set of
> > operations on those values; for example:
> >
> >     Type Nybble is range 0..15 with Size => 4;
> >     Subtype Prime_Nybble is Nybble with
> >       Static_Predicate => Prime_Nybble in 2|3|5|7|11|13;
> >
> > could be represented as something which visualized-as-text would be:
> >
> >    Nybble is
> >     Size            : Bits(4)
> >     Internal_Values : Set(0..15)
> >     Offset          : 0          -- So we could represent 1..16 w/ 4-bits
> >     Operations      : Arithmetic_ops & Scalar_Attributes
> >
> >
> >    Prime_Nybble modifying Nybble is
> >     Operations      : Operations without Scalar_Attributes
> >
> > or somesuch.
> 
> You describe here DDL and leave all semantics of the operations aside.

Are the semantics needed when semantic validity has been ensured by the semantic-analysis phase? 

> Prime numbers do not have arithmetic because arithmetic operations on 
> primes do not yield a prime. A semantically correct choice for "+" is 
> either leave it contravariant:
> 
>     function "+" (Left, Right : Prime) return Universal_Integer;
> 
> or drop it
> 
>     function "+" (Left, Right : Prime) return Prime is abstract;

Or we could simply assume Ada's model w/ subtypes. (i.e. that "+"(Left, Right : Integer) Return Integer can be used for subtypes like Natural.)

The IR is to model Ada programs, not behaviors.

> For attributes the choices are different. It depends on the properties 
> of the mathematical structure the [sub]type is to model. There is no way 
> the language could decide that. It can for built-in types, because they 
> are built-in.
> 
> [...]
> 
>  > Does that clear things up?
> 
> Yes, you are under the delusion that DDL is a type system. It is not, 
> DDL is weakly/untyped and as such is fundamentally incapable to describe 
> Ada type system, not even in first approximation.

No, you misunderstand -- my thought is that the Ada type-system (insofar as defining types) can be modeled in a DDL. DIANA was just such a system, an instance of IDL, and could represent Ada's type-declarations. QED.

What I'm looking for is a more unified, universal way to do so that encompass constraints generally.

  reply	other threads:[~2016-12-01  0:58 UTC|newest]

Thread overview: 195+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 23:49 Ada 2012 Constraints (WRT an Ada IR) Shark8
2016-11-29  8:17 ` G.B.
2016-11-29 20:32   ` Shark8
2016-11-29 20:44     ` Dmitry A. Kazakov
2016-11-29 20:51       ` Shark8
2016-11-29 21:06         ` Dmitry A. Kazakov
2016-11-29 22:59           ` Shark8
2016-11-30  8:31             ` Dmitry A. Kazakov
2016-11-30 18:28               ` Shark8
2016-11-30 20:26                 ` Niklas Holsti
2016-12-01  0:16                   ` Shark8
2016-12-01 22:15                     ` Randy Brukardt
2016-11-30 20:45                 ` Dmitry A. Kazakov
2016-12-01  0:58                   ` Shark8 [this message]
2016-12-01  8:55                     ` Dmitry A. Kazakov
2016-12-01 22:26                       ` Randy Brukardt
2016-12-02 16:21                         ` Dmitry A. Kazakov
2016-12-02 19:15                           ` Randy Brukardt
2016-12-03 10:21                             ` Dmitry A. Kazakov
2016-12-02 19:50                           ` G.B.
2016-12-03 10:23                             ` Dmitry A. Kazakov
2016-12-03 14:02                               ` G.B.
2016-12-03 16:26                                 ` Dmitry A. Kazakov
2016-12-04 15:28                                   ` Robert Eachus
2016-12-05  8:41                                     ` Stefan.Lucks
2016-12-05  8:58                                       ` Dmitry A. Kazakov
2016-12-05 11:09                                         ` Simon Wright
2016-12-05 18:42                                           ` Shark8
2016-12-05 22:13                                             ` Dmitry A. Kazakov
2016-12-06 20:51                                               ` Shark8
2016-12-06 21:07                                                 ` Dmitry A. Kazakov
2016-12-06 21:44                                                   ` Shark8
2016-12-06 23:23                                                     ` Randy Brukardt
2016-12-07 22:42                                                       ` Shark8
2016-12-07  1:08                                                     ` Dennis Lee Bieber
2016-12-07  6:36                                                       ` Niklas Holsti
2016-12-07 13:10                                                         ` Dennis Lee Bieber
2016-12-07 22:55                                                           ` Brian Drummond
2016-12-08  2:44                                                         ` Shark8
2016-12-07 10:04                                                       ` G.B.
2016-12-07 10:14                                                         ` G.B.
2016-12-07 10:51                                                         ` J-P. Rosen
2016-12-08 18:33                                                           ` G.B.
2016-12-09  8:26                                                             ` J-P. Rosen
2016-12-09  8:56                                                               ` G.B.
2016-12-10 15:13                                                                 ` Jacob Sparre Andersen
2016-12-11 19:50                                                                   ` Shark8
2016-12-05 22:07                                           ` Dmitry A. Kazakov
2016-12-06 23:09                                             ` Randy Brukardt
2016-12-07 10:03                                               ` Dmitry A. Kazakov
2016-12-07 22:37                                                 ` Randy Brukardt
2016-12-08  8:46                                                   ` Dmitry A. Kazakov
2016-12-10 15:24                                               ` Jacob Sparre Andersen
2016-12-09  9:12                                           ` Robert Eachus
2016-12-05 19:22                                         ` G.B.
2016-12-05 22:18                                           ` Dmitry A. Kazakov
2016-12-05 22:12                                         ` Randy Brukardt
2016-12-05 22:26                                           ` Dmitry A. Kazakov
2016-12-06  9:29                                             ` Simon Wright
2016-12-06 10:01                                               ` Dmitry A. Kazakov
2016-12-06 23:15                                             ` Randy Brukardt
2016-12-07 10:20                                               ` Dmitry A. Kazakov
2016-12-07 22:26                                                 ` Randy Brukardt
2016-12-08  8:57                                                   ` Dmitry A. Kazakov
2016-12-08  9:42                                                     ` G.B.
2016-12-08 10:03                                                       ` Dmitry A. Kazakov
2016-12-08 18:35                                                         ` G.B.
2016-12-09  9:38                                                           ` Dmitry A. Kazakov
2016-12-11 11:21                                                             ` G.B.
2016-12-11 12:28                                                               ` Dmitry A. Kazakov
2016-12-11 13:31                                                                 ` G.B.
2016-12-11 15:40                                                                   ` Dmitry A. Kazakov
2016-12-11 20:51                                                                     ` G.B.
2016-12-12  8:27                                                                       ` Dmitry A. Kazakov
2016-12-12 15:31                                                                         ` G.B.
2016-12-12 17:39                                                                           ` Dmitry A. Kazakov
2016-12-12 18:55                                                                             ` G.B.
2016-12-12 20:53                                                                               ` Dmitry A. Kazakov
2016-12-13  7:15                                                                                 ` G.B.
2016-12-13  8:27                                                                                   ` Dmitry A. Kazakov
2016-12-13 10:39                                                                                     ` G.B.
2016-12-13 11:19                                                                                       ` Dmitry A. Kazakov
2016-12-13 16:59                                                                                         ` G.B.
2016-12-13 21:11                                                                                           ` Dmitry A. Kazakov
2016-12-13 22:13                                                                                             ` Shark8
2016-12-14  8:42                                                                                               ` Dmitry A. Kazakov
2016-12-14 11:04                                                                                                 ` G.B.
2016-12-14 11:25                                                                                                   ` Dmitry A. Kazakov
2016-12-14 12:44                                                                                                     ` G.B.
2016-12-14 12:52                                                                                                       ` Dmitry A. Kazakov
2016-12-14 16:31                                                                                                         ` G.B.
2016-12-14 16:52                                                                                                           ` Dmitry A. Kazakov
2016-12-14 18:14                                                                                                             ` G.B.
2016-12-14 12:05                                                                                                 ` G.B.
2016-12-14 19:23                                                                                                 ` Shark8
2016-12-14 20:04                                                                                                   ` Dmitry A. Kazakov
2016-12-14 21:46                                                                                                     ` Shark8
2016-12-15  8:41                                                                                                       ` Dmitry A. Kazakov
2016-12-15 10:31                                                                                                         ` G.B.
2016-12-15 13:17                                                                                                           ` Dmitry A. Kazakov
2016-12-15 13:27                                                                                                             ` Dmitry A. Kazakov
2016-12-15 19:50                                                                                                             ` G.B.
2016-12-16 10:04                                                                                                               ` Dmitry A. Kazakov
2016-12-16 11:48                                                                                                                 ` G.B.
2016-12-16 12:56                                                                                                                   ` Stefan.Lucks
2016-12-16 19:59                                                                                                                     ` Randy Brukardt
2016-12-16 20:35                                                                                                                     ` G.B.
2016-12-17  9:33                                                                                                                       ` Stefan.Lucks
2016-12-19 22:57                                                                                                                         ` Randy Brukardt
2016-12-16 13:24                                                                                                                   ` Dmitry A. Kazakov
2016-12-15 14:34                                                                                                         ` Shark8
2016-12-15 14:53                                                                                                           ` Dmitry A. Kazakov
2016-12-15 22:34                                                                                                             ` Shark8
2016-12-16  8:28                                                                                                               ` Dmitry A. Kazakov
2016-12-17  3:46                                                                                                                 ` Shark8
2016-12-14 12:21                                                                                             ` G.B.
2016-12-14 12:55                                                                                               ` Dmitry A. Kazakov
2016-12-14 16:21                                                                                                 ` G.B.
2016-12-14 16:55                                                                                                   ` Dmitry A. Kazakov
2016-12-14 18:55                                                                                                     ` G.B.
2016-12-13 18:25                                                                                         ` Shark8
2016-12-13 21:11                                                                                           ` Dmitry A. Kazakov
2016-12-13 22:32                                                                                             ` Shark8
2016-12-14  8:54                                                                                               ` Dmitry A. Kazakov
2016-12-14 22:53                                                                                                 ` Randy Brukardt
2016-12-15  8:44                                                                                                   ` Dmitry A. Kazakov
2016-12-15 22:19                                                                                                     ` Randy Brukardt
2016-12-16  8:38                                                                                                       ` Dmitry A. Kazakov
2016-12-16 19:51                                                                                                         ` Randy Brukardt
2016-12-17  9:13                                                                                                           ` Dmitry A. Kazakov
2016-12-19 22:33                                                                                                             ` Randy Brukardt
2016-12-20 11:00                                                                                                               ` Dmitry A. Kazakov
2016-12-21  0:54                                                                                                                 ` Shark8
2016-12-21  0:59                                                                                                                 ` Randy Brukardt
2016-12-21 15:56                                                                                                                   ` Dmitry A. Kazakov
2016-12-21 18:26                                                                                                                     ` G.B.
2016-12-21 21:15                                                                                                                       ` Dmitry A. Kazakov
2016-12-22  9:54                                                                                                                         ` G.B.
2016-12-22 10:16                                                                                                                           ` Dmitry A. Kazakov
2016-12-14 11:46                                                                                             ` G.B.
2016-12-12 19:48                                                                             ` Shark8
2016-12-12 20:46                                                                               ` Dmitry A. Kazakov
2016-12-12 21:33                                                                                 ` Shark8
2016-12-13  8:28                                                                                   ` Dmitry A. Kazakov
2016-12-13 18:53                                                                                     ` Shark8
2016-12-13 21:11                                                                                       ` Dmitry A. Kazakov
2016-12-13 22:16                                                                                         ` Shark8
2016-12-14  9:00                                                                                           ` Dmitry A. Kazakov
2016-12-11 23:58                                                                   ` Paul Rubin
2016-12-12  8:33                                                                     ` Dmitry A. Kazakov
2016-12-12 15:23                                                                       ` G.B.
2016-12-12 15:51                                                                         ` G.B.
2016-12-09 21:46                                                     ` Randy Brukardt
2016-12-13 11:56                                         ` Alejandro R. Mosteo
2016-12-13 15:02                                           ` Dmitry A. Kazakov
2016-12-13 17:38                                             ` Alejandro R. Mosteo
2016-12-05 22:06                                       ` Randy Brukardt
2016-11-29 17:53 ` Niklas Holsti
2016-11-29 18:21   ` Dmitry A. Kazakov
2016-11-29 20:45   ` Shark8
2016-11-30  0:03     ` Randy Brukardt
2016-11-30  0:59       ` Shark8
2016-12-01 10:33   ` AdaMagica
2016-11-29 23:52 ` Randy Brukardt
2016-11-30  1:24   ` Shark8
2016-11-30 22:12     ` Randy Brukardt
2016-11-30  1:29   ` Shark8
2016-11-30 22:17     ` Randy Brukardt
2016-12-01  1:21       ` Shark8
2016-12-01 22:07         ` Randy Brukardt
2016-12-01 10:06   ` AdaMagica
  -- strict thread matches above, loose matches on Subject: below --
2016-12-09 21:41 Randy Brukardt
2016-12-09 22:32 ` Niklas Holsti
2016-12-13  0:41   ` Randy Brukardt
2016-12-13  2:34     ` Shark8
2016-12-13 22:35       ` Randy Brukardt
2016-12-14  0:38         ` Shark8
2016-12-13 20:45     ` Niklas Holsti
2016-12-13 23:19       ` Randy Brukardt
2016-12-14  0:53         ` Shark8
2016-12-14 22:22           ` Randy Brukardt
2016-12-13 22:45 Randy Brukardt
2016-12-14 22:40 Randy Brukardt
2016-12-15  8:48 ` Dmitry A. Kazakov
2016-12-15 22:24   ` Randy Brukardt
2016-12-16  8:40     ` Dmitry A. Kazakov
2016-12-16 19:46       ` Randy Brukardt
2016-12-16 20:14         ` Dmitry A. Kazakov
2016-12-19 22:52           ` Randy Brukardt
2016-12-20 10:59             ` Dmitry A. Kazakov
2016-12-21  0:50               ` Randy Brukardt
2016-12-21 15:56                 ` Dmitry A. Kazakov
2016-12-21 22:03 Randy Brukardt
2016-12-21 23:02 ` Shark8
2016-12-21 22:12 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