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,912597791e813f68 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-08 01:01:08 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: gautier_niouzes@hotmail.com (Gautier) Newsgroups: comp.lang.ada Subject: Re: advantages or disadvantages of ADA over pascal or modula Date: 8 Jan 2003 01:01:08 -0800 Organization: http://groups.google.com/ Message-ID: <17cd177c.0301080101.3f826bab@posting.google.com> References: NNTP-Posting-Host: 213.173.163.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1042016468 18522 127.0.0.1 (8 Jan 2003 09:01:08 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 8 Jan 2003 09:01:08 GMT Xref: archiver1.google.com comp.lang.ada:32734 Date: 2003-01-08T09:01:08+00:00 List-Id: Martin Klaiber: > I'm only an Ada-beginner, but I'd say that Ada is so much more powerful > than Pascal that they hardly can be compared at all. But I also found > three things which I miss in Ada compared to Borland Pascal. > > First, it would be nice, if an object in Ada would know it's own > variables without naming them explicitly. ... > It's not a big thing, but sometimes it leads to a lot of writing. Yes, > I know I can rename variables, but I still wonder why an object in Ada > doesn't know it's own variables. In fact, you are missing BP's prefixed OO notation (object.Method). You will certainly find fierce debates in c.l.a archives about it. I survive by using always "o" as the object parameter. The explicit has maybe the merit of readability over concision (analogous to Pascal's "with" and its absence in Ada). > Second, it would be nice, if Ada would allow to change internal > variables of an object also in functions. So, the following is not > valid code but it would be nice if it was, IMHO. > function IncMonth (Calendar : in out type_Calendar) return boolean; > function IncYear (Calendar : in out type_Calendar) return boolean; > Of course the same thing can be done with procedures and a boolean > parameter. But IMHO it's less elegant and less intuitive. [...] Also subject to debates... you say it's intuitive because you are accustomed to it. But look at your example. Normally, the basic role of a function is to give a value in function of other (the parameters). In your case the main information is what you do to "Calendar" and the result has a minor role - quite strange... It would be more elegant and intuitive (and also efficient) to write procedure IncMonth (Calendar : in out type_Calendar) is begin if Calendar.Month = 12 then IncYear (Calendar); Calendar.Month := 1; else Calendar.Month := Calendar.Month + 1; end if; end IncMonth; procedure function IncYear (Calendar : in out type_Calendar) is begin if Calendar.Year < 3000 then Calendar.Year := Calendar.Year + 1; else raise Year_out_of_range; end if; end IncYear; Don't forget, you have the exceptions... it saves a lot of transporting error codes and acrobatic expressions... ________________________________________________________ Gautier -- http://www.mysunrise.ch/users/gdm/gsoft.htm NB: For a direct answer, e-mail address on the Web site!