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 autolearn=ham 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-10 14:51:40 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!chcgil2-snh1.gtei.net!chcgil2-snf1.gtei.net!news.gtei.net!news.binc.net!kilgallen From: Kilgallen@eisner.decus.org.nospam (Larry Kilgallen) Newsgroups: comp.lang.ada Subject: Re: Ada Idioms Progress Preview Date: 10 Aug 2001 16:51:35 -0500 Organization: LJK Software Message-ID: References: <3B6F1B2F.4FC3C833@gsde.hou.us.ray.com> <5ee5b646.0108071819.6e84e33d@posting.google.com> <3_Xc7.45$NM5.84779@news.pacbell.net> NNTP-Posting-Host: eisner.encompasserve.org X-Trace: grandcanyon.binc.net 997479787 19348 192.135.80.34 (10 Aug 2001 21:43:07 GMT) X-Complaints-To: abuse@binc.net NNTP-Posting-Date: Fri, 10 Aug 2001 21:43:07 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:11785 Date: 2001-08-10T16:51:35-05:00 List-Id: In article <3_Xc7.45$NM5.84779@news.pacbell.net>, "Jay Nabonne" writes: > As a C/C++ programmer who is looking with interest at Ada (after a rather > entertaining discussion about Code Red in comp.lang.c++), what would be most > 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 criterion for success is that someone reading your code cannot tell whether your background is C or Fortran. (Or anything else, but the original statement, so far as I can tell, is "It is possible to write Fortran in any language".) WWW.AdaPower.com should have an item on "Ada for C programmers" that gives some ideas of the ways "not" to do it. Perhaps one technique for those whose background is Csomething is to think very hard in an Ada program before taking the address of something. Generally it is not necessary, but there is a tendency to do it if C is on your mind. Another trick might be not to assume you can guess what the machine code is going to look like. Passing a record as a parameter is _not_ less efficient than passing a pointer, since what Ada does under the covers is typically a pointer. Of course things that don't involve instruction-level efficiencies are no different -- if you read every block on the disk it will still take a while, so higher level program efficiency rules still count.