comp.lang.ada
 help / color / mirror / Atom feed
From: Mehdi Saada <00120260a@gmail.com>
Subject: Re: [Newbie] doubly constrained array, dumb question
Date: Mon, 26 Feb 2018 17:29:15 -0800 (PST)
Date: 2018-02-26T17:29:15-08:00	[thread overview]
Message-ID: <473f9b1a-6466-4745-9041-107f54062cf2@googlegroups.com> (raw)
In-Reply-To: <62f83fe5-15d6-41cf-952f-bc3cb077d42f@googlegroups.com>

> Dmitry said:
> 1. array's index
> 2. array's element
> 3. record's component
> 4. access type's target type
> 5. discriminant
> 6. argument of a subroutine access type
> 7. class-wide types (closed range of descendants T'Class (T..S))
> 8. tagged type primitive operations (disallowing operations)
> 9. protected and task type entries (disallowing operations)
> 10. task type entry family

Oh, I also arrived at that conclusion for the first five + seventh, I didn't imagine the sixth but there's no reason one shouldn't be able to do that.
For 8: a class has any sense at all only if there's no dispatching to an inexistent method, and your forbidding some methods would do the same, raise an exception.
So to avoid that, if you want to disallow operations (without make a dispatching call to it raises an exception), you have to cut the tagged type from its root, by hiding the fact it has a parent type, so as to disinherit the parent's method.
If you don't want that, (I suppose) one would have to implement a per-operation basis dispatching mechanism with a list of allowed types for each methods ?

I don't know enough protected types or task types, but I think you can hide protected operations/entry types as easily, I suppose you can hide the type's progenitors too. Too bad I'm in the middle of writing a line editor (AdaTutor assignement 5), I can't test that.

Could you give an example of 10, the syntax you would like ?

... I wanted to have an anonymous string subtype in a record. Shouldn't have been terribly important. I made without, but had to add a discriminant Length, which is idiotic since the only use for my record type is to be allocated dynamically, and the string field would always be initialized. In that case I wouldn't risk anything by having
type LINK is record
  Next: access LINK;
  TEXT:String;
end record; being legal.
... since all use would be like this: some_access_to_link := new (Next_link, new STRING(TEXT_INPUT)), and TEXT_INPUT would carry its Length information with it and the object would always have a fixed length.

  parent reply	other threads:[~2018-02-27  1:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-26 16:26 [Newbie] doubly constrained array, dumb question Mehdi Saada
2018-02-26 17:02 ` J-P. Rosen
2018-02-26 21:40   ` Dmitry A. Kazakov
2018-02-26 23:26   ` Randy Brukardt
2018-02-27  9:01     ` Simon Wright
2018-02-27 22:11       ` Randy Brukardt
2018-02-26 20:52 ` Niklas Holsti
2018-02-27  1:29 ` Mehdi Saada [this message]
2018-02-27  9:18   ` Dmitry A. Kazakov
2018-02-27 11:43     ` Mehdi Saada
2018-02-27 14:19       ` Dmitry A. Kazakov
2018-02-27 17:08     ` G. B.
2018-02-27 17:37       ` Dmitry A. Kazakov
2018-02-27 14:34   ` Jere
2018-02-27 15:13     ` Dmitry A. Kazakov
2018-02-27  7:38 ` Jacob Sparre Andersen
replies disabled

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