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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e55245590c829bef X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Mart van de Wege Newsgroups: comp.lang.ada Subject: Re: Beginners question: Compound types, how-to? Date: Mon, 01 Nov 2010 18:06:19 +0100 Message-ID: <86y69d3rec.fsf@gareth.avalon.lan> References: <86wroy58ff.fsf@gareth.avalon.lan> <86pqup5xfy.fsf@gareth.avalon.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net BrOCc/F0VN89aSl64ldBnA4vSknf6j9ErbnFlO0hPhuCguN0Zh X-Orig-Path: gareth.avalon.lan!not-for-mail Cancel-Lock: sha1:TAIijtNQzJx7I/D22IgTMzAnJr0= sha1:MWfVBA8ecnjF/aGphvARzMEHGuc= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Xref: g2news2.google.com comp.lang.ada:16078 Date: 2010-11-01T18:06:19+01:00 List-Id: Shark8 writes: > On Nov 1, 1:12 am, Mart van de Wege wrote: >> Jeffrey Carter writes: >> >> Thanks to Jeffrey and the others. Yes, this was an elementary mistake, >> and I kept overlooking it because I also have C experience, so I kept >> reading Character as a perfectly fine identifier and dismissing Char >> because I thought it was a reserved word. >> >> I should have realised sooner that Ada uses full words, not >> abbreviations, whenever possible. >> >> I recompiled with Char as the type name; it looks ugly, but I think I >> know a way around that, but that involves inheritance, and I am not >> touching that just yet. >> >> My test code works fine now. I am relieved at least to know that my >> logic was sound, even if the code wasn't particularly. >> >> Mart >> -- >> "We will need a longer wall when the revolution comes." >>     --- AJS, quoting an uncertain source. > > You could have appended "_Type" to the type declaration giving > "Character_Type." > This gives the added advantage of allowing your parameters to be > highly descriptive, especially if you use named-association when > calling the parameters. > That's another way around it. Nice. Thanks. > Ex: > Procedure Do_Damage( Character : In Out Character_Type; Amount : In > Positive ); -- the spec for a procedure > > -- using the procedure > declare > Dave : Character_Type:= Randomize_Stats; -- > Initialize a character > begin > ... > -- Dave was hit in a bar-fight for 3 damage > Do_Damage( Amount => 3, Character => Dave ); -- Note > that with named association you may put the parameters in arbitrary > order > ... > end; I wasn't planning on going that far. I am aiming on implementing just enough of the rules to spare me the horrid paperwork in planning and running games. After all, that's what computers are for. And so far, my first impression of Ada is that it's a nice language. It's finicky, but not as bad as people make it out to be on that front. Mart -- "We will need a longer wall when the revolution comes." --- AJS, quoting an uncertain source.