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=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,45b47ecb995e7a3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-13 07:05:39 PST Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!sn-xit-04!supernews.com!feed.textport.net!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: <3B6F1B2F.4FC3C833@gsde.hou.us.ray.com> <5ee5b646.0108071819.6e84e33d@posting.google.com> <3_Xc7.45$NM5.84779@news.pacbell.net> Subject: Re: Ada Idioms Progress Preview Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Mon, 13 Aug 2001 10:05:24 EDT Organization: http://www.newsranger.com Date: Mon, 13 Aug 2001 14:05:24 GMT Xref: archiver1.google.com comp.lang.ada:11845 Date: 2001-08-13T14:05:24+00:00 List-Id: In article <3_Xc7.45$NM5.84779@news.pacbell.net>, Jay Nabonne says... > >useful for me - and it's what I thought of when I saw the word idiom - is >something that says "in order to do , given that there's more than one >way to do it within the Ada language, here's how you write code that looks >like an Ada programmer wrote it and doesn't look like a >C++-programmer-writing-Ada wrote it.". > >I'm interested in how to "think in Ada"... The best advice I can give you today is to go to the Ada Source Code Treasury at http://www.adapower.com/adacode.html . The master site itself is useful too. Based on my experience with native C speakers, here are some basic things to get you started: o Strings in Ada are *very* different from Strings in C. Ada strings end at the end of the array (or slice of it you specify), not at some arbitrarily-chosen "terminator" character. Look into the "&" operator for arrays, and the array attributes 'length, 'first, and 'last. 'image is damn nice too. Don't be discouraged if you have trouble with this seemingly simple thing. Conceptually, this is probably the biggest difference the languages have. o The techniques you learn for dealing with strings can be used for *all* arrays. o Make yourself familiar with the language defined attributes ( http://www.ada-auth.org/~acats/arm-html/RM-K.html ). o Passing a large data structure as a parameter does *not* mean that the whole thing gets copied. The compiler will internally pass a reference to the structure if that would be more efficient. Do *not* use pointers yourself to force this effect. o You almost never need pointers. o If you think you need a pointer, see the previous point. :-) --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com