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=-2.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, XPRIO_SHORT_SUBJ autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d91acedab4502702,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-14 22:03:38 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!easynet-quince!easynet.net!mephistopheles.news.clara.net!news.clara.net!usenet-fr.net!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: "Andrew Carroll" Newsgroups: comp.lang.ada Subject: Modes Date: Tue, 14 Oct 2003 19:36:09 -0600 Organization: Cuivre, Argent, Or Message-ID: References: <20031014202516.4999F4C40B9@lovelace.ada-france.org> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: melchior.cuivre.fr.eu.org 1066194129 72739 80.67.180.195 (15 Oct 2003 05:02:09 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Wed, 15 Oct 2003 05:02:09 +0000 (UTC) To: Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Gateway to the comp.lang.ada Usenet newsgroup List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:878 Date: 2003-10-14T19:36:09-06:00 > On 10 Oct 2003 11:18:28 -0400, Stephen Leake wrote: > >"Andrew Carroll" wrote: > ... > >Tagged types and full limited types are always passed by reference, > >because it almost always matters for them. > ... I wish I had writen that. There's another Andrew here. Great name by the way! I guess I'll start singing my emails different. I did post some information about using pointers to strings and started the Modes topic. So, to follow up. I revisited all the classes I am working on. Their not really classes now. Just records. I made them private and followed Cohen's form. All that work wasn't really that informative. It just re-highlighted some things that will take some time to get used to with Ada. For instance if I had a record that contained a count (private record that is) like package x is type x_type is private; type xptr is access all x_type; function getcount(this: x_type)return Integer; private type x_type is private record count: Integer := 0; end record; end x; If I want a method to get the count I have to pass in an instance of what I want to get the count from. Like: ... var: xptr; num: integer; var := new x_type; num := getcount(var); ... I come from C++, Java so that looks more like linear programming to me. That is, without the dot notation like var.getCount(); Just something to get used to. I got the "modes" covered now as well. The only thing I noticed after I changed some stuff with modes and the records is that it seems to compile faster and run slower. Didn't expect that but...what can I say? So I'm working on the string stuff now. I'm pretty sure you all knew this but there is a String_Access defined in Unbounded_String and in Gnat.OS_Lib. What a coinkidink. Something else I didn't know "For parameter types unconstrained types are allowed, similar to passing int array[] in C. " (Ada-95: A guide for C and C++ programmers by Simon Johnston) So, if I have a function makeString(input: String) return String then I can pass in a string of most any size, then return it. Don't know if this is really helpfull yet. Ohhh, by the way. No one posted a list of the "rules of thumb" for Ada. Here, I'll repost my post: >[snip] >> The rule of thumb is: newer use pointers if there is an alternative. >> So: >[snip] >>Thus another rule: if a pointer, then when possible anonymous: >> procedure Add (This: access X; Token: Unbounded_String); >> -- This will be a primitive subprogram of X >> >[snip] >> The Ada way is not to create objects you do not need. >Okay, so now we're getting to the information I want to know. >The "rules of thumb" for the "Ada idiom". Anyone got a list of >"standardized rules of thumb for the Ada idiom"? Well, take care all. Andrew C.