comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Klaiber <martinkl@zedat.fu-berlin.de>
Subject: Re: advantages or disadvantages of ADA over pascal or modula
Date: Wed, 8 Jan 2003 12:13:18 +0100
Date: 2003-01-08T12:13:18+01:00	[thread overview]
Message-ID: <endte-t51.ln1@martinkl.dialup.fu-berlin.de> (raw)
In-Reply-To: 17cd177c.0301080101.3f826bab@posting.google.com

Gautier <gautier_niouzes@hotmail.com> wrote:
> Martin Klaiber:

>> First, it would be nice, if an object in Ada would know it's own
>> variables without naming them explicitly.

> 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.

Yes, I've read some of these debates. I don't prefer one notation over
the other. Both have their advantages and disadvantages IMHO.

> The explicit has maybe the merit of readability over concision

Hm, depends on. Redundancy can affect readability too.

>> Second, it would be nice, if Ada would allow to change internal
>> variables of an object also in functions.

> Also subject to debates... you say it's intuitive because you are
> accustomed to it. 

Yes, that might be true.

> But look at your example. Normally, the basic role of a function is to
> give a value in function of other (the parameters).

Here the parameter is in the function-name. I could have written it
also as (skipped a bit to keep the line short):

  function IncMonth (Calender : ...; Days : Positive) return boolean;

> In your case the main information is what you do to "Calendar" and the
> result has a minor role - quite strange...

Well, this depends on how you want to use such functions. I like to use
them like that:

  if IncMonth (Calendar) = true then
    Update (Anything);
  end if;

> 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;

Will this really work like that? Calendar.Month must not be set to 1
if IncYear fails. Does this mean, if exception Year_out_of_range is
raised, the rest of the code in IncMonth will be skipped?

> Don't forget, you have the exceptions... it saves a lot of transporting
> error codes and acrobatic expressions...

Yes, these exceptions are phantastic. I really have to get used to them.

Martin



  reply	other threads:[~2003-01-08 11:13 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-03 15:57 advantages or disadvantages of ADA over pascal or modula karl bowl
2003-01-04  2:36 ` Adrian Knoth
2003-01-04 23:12   ` Robert C. Leif
2003-01-05  2:56     ` Ted Dennison
2003-01-05  3:54       ` John R. Strohm
2003-01-06  5:55         ` AG
2003-01-05  9:38           ` John R. Strohm
2003-01-06  1:37             ` advantages or disadvantages of ADA over pascal or modula or oberon was " Robert C. Leif
2003-01-04  2:56 ` Steve
2003-01-04 11:34   ` Dmitry A. Kazakov
2003-01-04 17:35     ` Steve
2003-01-04 22:16       ` Vinzent Hoefler
2003-01-05 14:12       ` Dmitry A. Kazakov
2003-01-04 12:17 ` Gautier
2003-01-04 17:12 ` Alfred Hilscher
2003-01-04 18:16   ` Ted Dennison
2003-01-05 11:47   ` karl bowl
2003-01-05 18:53     ` Alfred Hilscher
2003-01-05 20:38       ` Vinzent Hoefler
2003-01-05 21:03         ` Alfred Hilscher
2003-01-05 21:20           ` Vinzent Hoefler
2003-01-05 21:31             ` Alfred Hilscher
2003-01-05 21:47               ` Vinzent Hoefler
2003-01-06 14:43                 ` Gautier
2003-01-06 16:21                   ` Alfred Hilscher
2003-01-05 22:57             ` Vinzent Hoefler
2003-01-06 21:57           ` karl bowl
2003-01-18 14:14     ` Alfred Hilscher
2003-01-18 15:26       ` Larry Kilgallen
2003-01-19 18:10         ` Alfred Hilscher
2003-01-19 23:42           ` Larry Kilgallen
2003-01-21 19:16           ` Robert A Duff
2003-01-18 21:39       ` John R. Strohm
2003-01-18 21:56         ` Vinzent Hoefler
2003-01-18 23:08           ` Larry Kilgallen
2003-01-18 23:16           ` John R. Strohm
2003-01-19  3:36             ` Hyman Rosen
2003-01-19  4:47               ` Vinzent Hoefler
2003-01-19  5:47               ` John R. Strohm
2003-01-19  5:50               ` Steve
2003-01-19  4:47             ` Vinzent Hoefler
2003-01-19  5:51               ` John R. Strohm
2003-01-19 12:51                 ` Dmitry A. Kazakov
2003-01-19 16:43                 ` Marin David Condic
2003-01-19 23:26                   ` John R. Strohm
2003-01-21 13:45                     ` Marin David Condic
2003-01-19  6:10             ` Kevin Cline
2003-01-19 18:03               ` Bernd Specht
2003-01-19 16:31             ` Marin David Condic
2003-01-19 12:17         ` Engineers Pay Alan and Carmel Brain
2003-01-21  7:12           ` Kevin Cline
2003-01-21  9:14             ` John R. Strohm
     [not found]             ` <hub1g-vu3.ln1@beastie.ix.netcom.com>
2003-01-22  4:11               ` John R. Strohm
2003-01-22 17:56               ` John R. Strohm
2003-01-19 16:19         ` advantages or disadvantages of ADA over pascal or modula Marin David Condic
2003-01-19 19:08           ` Robert C. Leif
2003-01-19 20:26           ` Dale Stanbrough
2003-01-20  8:22             ` Tor Fredrik Aas
2003-01-21 14:00             ` Marin David Condic
2003-01-19 18:22         ` Alfred Hilscher
2003-01-20 10:35         ` Georg Bauhaus
2003-01-20 21:12           ` John R. Strohm
2003-01-20 15:56       ` karl bowl
2003-01-20 17:39         ` Jerry Petrey
2003-01-20 22:47         ` Alfred Hilscher
2003-01-21 14:55           ` Stephen Leake
2003-01-21 21:55             ` Alfred Hilscher
2003-01-23 17:06               ` Stephen Leake
2003-01-27  4:25                 ` AG
2003-01-26 17:11                   ` Alfred Hilscher
2003-01-21 17:23           ` karl bowl
2003-01-21 21:47             ` Alfred Hilscher
2003-01-05 12:42   ` Gautier
2003-01-05 18:58     ` Alfred Hilscher
2003-01-05 22:28       ` tmoran
2003-01-06 20:33         ` Randy Brukardt
2003-01-07 14:47           ` Alfred Hilscher
2003-01-07 18:56             ` Randy Brukardt
2003-01-08  9:43               ` Alfred Hilscher
     [not found] ` <mji5va.994.ln@beastie.ix.netcom.com>
2003-01-04 22:16   ` Vinzent Hoefler
2003-01-07 18:14 ` Martin Klaiber
2003-01-08  9:01   ` Gautier
2003-01-08 11:13     ` Martin Klaiber [this message]
2003-01-08 17:25       ` Gautier
2003-01-08 17:52         ` Martin Klaiber
2003-01-10  3:07 ` Richard Riehle
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox