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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9c8533728e8d73d0 X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Please help a beginner! (second try) Date: 1996/02/18 Message-ID: #1/1 X-Deja-AN: 139903316 references: <4g517q$438@helios.herts.ac.uk> <4g675n$dm4@news.pacifier.com> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-02-18T00:00:00+00:00 List-Id: Steve said "Well, in Ada the main program is a procedure: PROCEDURE Main IS BEGIN END Main; Careful Steve, this is wrong, you cannot have compiled it, you meant procedure Main is begin null; end Main; Also, Steve's final solution for the procedure: with TEXT_IO; procedure main is package INT_IO is new TEXT_IO.INTEGER_IO(INTEGER); procedure proc1 is begin TEXT_IO.PUT("Hello"); INT_IO.PUT(2); end proc1; begin TEXT_IO.PUT("Hello"); INT_IO.PUT(2); end main; is very confused, it seems to be the result of random code rearrangement until something "works". In the above, which is not properly indented, no doubt adding to the confusion, you have an internal procedure proc1 which is never called. A corrected version of the above is: with Ada.Text_IO; procedure Main is package Int_IO is new Ada.Text_IO.Integer_IO (Integer); begin Ada.Text_IO.Put ("Hello"); Int_IO.Put (2); end Main; However, I prefer not to teach generic instantiation so early (I would bet for example that Steve does not 100% understand what he wrote there :-) Instead in Ada 95, I would teach: with Ada.Text_IO; with Ada.Integer_Text_IO; procedure Main is begin Ada.Text_IO.Put ("Hello"); Ada.Integer_Text_IO.Put (2); end Main; Of course this only works with the built-in type Integer, but one of the few legitimate uses of the built-in types is in teaching right at the beginning. I also changed the casing to be more "standard". The use of all upper case identifiers is now largely out of favor, so you might as well teach the above casing style from the start. Another approach is to introduce the attribute functions early on: with Ada.Text_IO; procedure Main is begin Ada.Text_IO.Put ("Hello"); Ada.Text_IO.Put (Integer'Image (2)); end Main; One general comment is that if you are trying to understand Ada, or any other language, at an elementary level like this, get a book and read it! Using a newsgroup to try to learn at this level is a dicey proposition, because sure there are people who can answer correctly, but the information you get posted on any newsgroup is quite unreliable. On CLA for instance, while it is better than some other newsgroups, people routinely through accident or ignorance post as gospel statements about Ada that are completely wrong, and if you don't know a fair amount to start with, you can easily get confused. To those who post suggested solutions to anything, a plea: PLEASE be sure to compile and test your solution. Even if you know Ada well, it is good insurance against a simple slip-up which can cause great confusion. For example, I compiled and ran all three examples above, they are very simple, and did indeed run error-free with no surprises, but no one can be 100% sure of not making silly mistakes :-)