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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8077d2e20cde67b1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-10-24 19:34:51 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!dyn179-ras38.screaming.NET!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: Modular types inside records Date: Wed, 25 Oct 2000 02:50:07 +0100 Message-ID: <8t5gs7$m1sl5$2@ID-25716.news.cis.dfn.de> References: <8FD47616EPablo@213.25.200.9> <8ss7fb$5c7$1@nnrp1.deja.com> <8FD4BD4F4Pablo@213.25.200.9> <8FD6C49EFPablo@213.25.200.9> NNTP-Posting-Host: dyn179-ras38.screaming.net (212.188.133.179) X-Trace: fu-berlin.de 972441287 23130789 212.188.133.179 (16 [25716]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Xref: supernews.google.com comp.lang.ada:1531 Date: 2000-10-25T02:50:07+01:00 List-Id: Totally off-base, Pawel! One of the things you must learn, if you are going to become a professional Ada programmer, is what is grandly called 'decoupling'. This means, in essence, making the interfaces between modules as simple as reasonably possible. In the case of bottom-up programming (which includes your example), this generally means making the interface as simple as (reasonably) possible for 'users' of your package. Does adding the 'mod_n_max' generic parameter make things easier for users of your package? It surely does not. Trust me, something like: if Front = Buffer'Last then Front := Buffer'First; else Front := Buffer_Index'Succ(Front); end if; is a terrifically simple piece of code, as code goes. In your time, you will come across multi-KSLOC Gorgons that will make you have to change your underpants. You will come to eat the kind of fragmentette above in one gulp. Oh harken ye to the words of the old and grizzled: it's not the car that has the fanciest gadgets that wins the race, it's the one that manages to actually finish the race. Another way to think of it is like this: programming is not an art, it's just a way of getting a job done. And, believe me, this comes from a man who deeply believes that programming is an art. Or, another way is this: you have to know a lot in order to know a little. Okay, so how do we 'pros' do it, then? By declaring a 'Cyclic_Succ' function of course: generic type Element_Type is (<>); function Cyclic_Succ (Item: in Element_Type) return Element_Type; Neat huh? I'll leave the implementation and use of this function to you. All the best, -- Nick Roberts http://www.AdaOS.org PS: If you need to remove Constraint_Error checks, for speed, you can use pragma Suppress (after testing).