From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_50,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fd26676e94ec9b24,start X-Google-Attributes: gid103376,public From: G Subject: Simple Case Study in Types. Chords. Date: 1999/11/16 Message-ID: <3831283B.20807F08@interact.net.au>#1/1 X-Deja-AN: 549207452 Content-Transfer-Encoding: 7bit Organization: Humanity X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-16T00:00:00+00:00 List-Id: With the following code fragments, I am not sure if I constructed the types in [Chord_Definition.ads] such that they actually mean what I think they do. (I have not worried about keys because that is unneccessary and I am not planning on learning musical software design - this is an exercise in type-casting and accessing records, for me). Please look through this brief code. The [Chord_List] contains thirteen elements to account for twelve semi-tones and the octave (13th). If I was to assign a [Major_Chord] variable as an instance of record [Chord_Fragment] I would need to define the [Chord_List] array as containing the [one], [four] and [eight] elements of type Twelve_Tone. Allowing that I have got my arrays and things in the right places (even if they don't mean quite what I think they do), what small ada code allows me to assign such a value to a variable [Major_Chord] ? -------------------------------- -- Chord_Definition.ads -- a specification for a package -- which defines chords -------------- package Chord_Definition is type chord is abstract tagged null record; type Twelve_Tone is -- Thirteen because that allows the octave. (One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen); type Chord_List is array (1..13) of Twelve_Tone; type Chord_Fragment is new Chord with record Current_Chord : Chord_List; end record; -- type Chord_Access is access Chord; -- (not sure about access types yet) end Chord_Definition; ---------------------- ------------------------------ -- Chord_Progression.adb -- a simple procedure : --------------------- with Chord_Definition; procedure Chord_Progression is -- A sequence for compositional chord sequences. type Chord_Sequence is array (1..Chord_Definition.Chord_List'Last) of Chord_Definition.Chord_Fragment; -- I think I bodged that (?) with Chord_Sequence -- because I wanted to be able to define -- a sequence of variable chord_fragments. -- assign major_chord, minor_chord, etc. , but how ? begin --- (...do stuff with chords...) end Chord_Progression; --------------------------------------------