comp.lang.ada
 help / color / mirror / Atom feed
* How discriminants interplay with derived tagged types?
@ 2017-11-26 23:00 Victor Porton
  2017-11-27  8:32 ` Dmitry A. Kazakov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Victor Porton @ 2017-11-26 23:00 UTC (permalink / raw)


Below three is a fragment of my real code.

It uses both discriminants and derived tagged types. I am not sure I well 
understand how they interplay.

Please explain how discriminants and derived tagged types interplay.


with Ada.Containers.Indefinite_Holders;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

package Boiler.RDF_Format.Resource is

   type Script_Kind_Enum is (Transformer, Validator);

   type Transformer_Kind_Enum is (Entire, Sequential, Up_Down, Down_Up);

   type Validator_Kind_Enum is (Entire, Parts);

   package String_Holder is new Ada.Containers.Indefinite_Holders(String);

   type Script_Info (Script_Kind: Script_Kind_Enum) is tagged
      record
         Completeness, Stability, Preference: Long_Float; -- or better just 
Float?
         -- TODO: Distinguishing transformer and validator scripts does not 
conform to the specification
         case Script_Kind is
            when Transformer =>
               Transformer_Kind: Transformer_Kind_Enum;
            when Validator =>
               Validator_Kind  : Validator_Kind_Enum;
         end case;
      end record;

   type Command_Script_Info is new Script_Info with
      record
         Language: URI_Type;
         Min_Version, Max_Version: String_Holder.Holder;
         Script_URL:     String_Holder.Holder;
         Command_String: String_Holder.Holder;
         OK_Result: String_Holder.Holder;
      end record;

   type Web_Service_Script_Info is new Script_Info with
      record
         Action: RDF.Redland.URI.URI_Type;
         Method: Unbounded_String;
         XML_Field: Unbounded_String;
      end record;

end Boiler.RDF_Format.Resource;


-- 
Victor Porton - http://portonvictor.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How discriminants interplay with derived tagged types?
  2017-11-26 23:00 How discriminants interplay with derived tagged types? Victor Porton
@ 2017-11-27  8:32 ` Dmitry A. Kazakov
  2017-11-28  1:57 ` Randy Brukardt
  2017-11-28 18:44 ` AdaMagica
  2 siblings, 0 replies; 4+ messages in thread
From: Dmitry A. Kazakov @ 2017-11-27  8:32 UTC (permalink / raw)


On 27/11/2017 00:00, Victor Porton wrote:

> Please explain how discriminants and derived tagged types interplay.

Discriminants are either

1. inherited. E.g.

    type T (X : Integer) is tagged ...;
    type S is new T with ...;

S has X as the discriminant. In this case the discriminant part is omitted.

2. Overridden. When the new type must have a different set of 
discriminants, the discriminant part appears:

    type U (B : Boolean; X : Integer) is new T (X) with ...;

and the discriminants of the parent type are set this or that way. In 
the example U's discriminant X is used to set T's dicsriminant X.

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How discriminants interplay with derived tagged types?
  2017-11-26 23:00 How discriminants interplay with derived tagged types? Victor Porton
  2017-11-27  8:32 ` Dmitry A. Kazakov
@ 2017-11-28  1:57 ` Randy Brukardt
  2017-11-28 18:44 ` AdaMagica
  2 siblings, 0 replies; 4+ messages in thread
From: Randy Brukardt @ 2017-11-28  1:57 UTC (permalink / raw)


"Victor Porton" <porton@narod.ru> wrote in message 
news:ovfh2i$127m$1@gioia.aioe.org...
...
> Please explain how discriminants and derived tagged types interplay.

Do you have a year? Are you planning to become a language lawyer and join 
the ARG for language maintenance?

If either of these are false, I'd suggest forgetting about it and coming up 
with some other strategy. ;-)

                                  Randy.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How discriminants interplay with derived tagged types?
  2017-11-26 23:00 How discriminants interplay with derived tagged types? Victor Porton
  2017-11-27  8:32 ` Dmitry A. Kazakov
  2017-11-28  1:57 ` Randy Brukardt
@ 2017-11-28 18:44 ` AdaMagica
  2 siblings, 0 replies; 4+ messages in thread
From: AdaMagica @ 2017-11-28 18:44 UTC (permalink / raw)


Am Montag, 27. November 2017 00:00:39 UTC+1 schrieb Victor Porton:
> Please explain how discriminants and derived tagged types interplay.

Just try to figure out in which sequence the components in T4 appear, i.e. in which sequence you would have to write them down in a positional aggregate for an object of type T4:

type T (D: Discriminant) is tagged record
  <T-Components>
end record;

type T1 is new T (D => X) with record
  <T1-Components>
end record;

type T2 (D2: Discr) is new T1 with record
  <T2-Components>
end record;

type T3 (D4: Diskr; D3: Diskr_3) is new T2 (D2 => D4) with record
  <T3-Components>
end record;

type T4 is new T3 with record
  <T4-Components>
end record;

(Hint: Discr. appear first.)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-28 18:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-26 23:00 How discriminants interplay with derived tagged types? Victor Porton
2017-11-27  8:32 ` Dmitry A. Kazakov
2017-11-28  1:57 ` Randy Brukardt
2017-11-28 18:44 ` AdaMagica

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