comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <eachus@mitre.org>
Subject: Re: Ada vs Delphi?
Date: 1999/08/17
Date: 1999-08-17T22:58:22+00:00	[thread overview]
Message-ID: <37B9E9F2.D97B79B7@mitre.org> (raw)
In-Reply-To: 37b54730.55126310@news.total.net

Andre Ratel wrote:
  
> But how do you avoid complex expressions becoming cumbersome?
 
    By defining the operators you need so that the code makes sense. 
For example:

  function Clock return Tick;
  type Tick is new Integer; -- lets assume a 1 millisecond clock.
  type Seconds is delta 0.001 digits 6; -- let's use a decimal type for
kicks.
  type Minutes is range -186400..186399;
  ...
  function "+" (L: Tick; R: Seconds) return Seconds;
  function "+" (L: Tick; R: Seconds) return Tick;
  pragma Inline("+"); -- applies to both functions.
  ...
  function "+" (L: Tick; R: Seconds) return Seconds is
  begin return Seconds(L)/1000 + R; end "+";
  function "+" (L: Tick; R: Seconds) return Tick is 
  begin return L + Tick(R * 1000); end "+";

  Now you can write:

    Total_Waiting_Time: Seconds := 0.0;
  ...
  function Something;
    Now: Tick := Clock;
  begin -- waiting ;-)
    Acquire_Lock;
    Actually_Do_Something;
    Release_Lock;
    Total_Waiting_Time := Total_Waiting_Time + Clock - Now;
  end;  
  
  Of course, this is all expository.  You don't want to do that, even
when you are writing a simulation package because the language provides
two time packages (Ada.Calendar and Ada.Real_Time) plus a type
Standard.Duration with many types and conversions already defined.  (In
addition if you use a predefined time type, you can use it in delay and
delay until statements.)

-- 

                                        Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




  reply	other threads:[~1999-08-17  0:00 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-06  0:00 Ada vs Delphi? Andre Ratel
1999-08-06  0:00 ` Steve Doiel
1999-08-09  0:00   ` Paul Groves
1999-08-08  0:00     ` Steve Doiel
1999-08-10  0:00       ` Ray Blaak
1999-08-10  0:00         ` Steve Doiel
1999-08-14  0:00           ` Andre Ratel
1999-08-09  0:00     ` Gautier
1999-08-11  0:00       ` Andre Ratel
1999-08-12  0:00         ` Gautier
1999-08-14  0:00           ` Andre Ratel
1999-08-14  0:00             ` Gautier
1999-08-16  0:00               ` Gautier
1999-08-15  0:00             ` Steve Doiel
1999-08-17  0:00             ` Robert I. Eachus
1999-08-12  0:00         ` Gautier
1999-08-09  0:00     ` Robert Dewar
1999-08-09  0:00     ` Robert Dewar
1999-08-11  0:00       ` Andre Ratel
1999-08-11  0:00         ` Robert Dewar
1999-08-14  0:00           ` Andre Ratel
1999-08-17  0:00             ` Robert I. Eachus [this message]
1999-08-11  0:00         ` Robert Dewar
1999-08-11  0:00           ` David Botton
1999-08-14  0:00           ` Andre Ratel
1999-08-11  0:00         ` Ted Dennison
1999-08-14  0:00           ` Andre Ratel
1999-08-16  0:00             ` Ted Dennison
1999-08-09  0:00     ` Aidan Skinner
1999-08-10  0:00     ` Brian Rogoff
1999-08-11  0:00       ` Scientific calculations (was Re: Ada vs Delphi? ) Vladimir Olensky
1999-08-11  0:00         ` Robert Dewar
1999-08-11  0:00         ` Robert Dewar
1999-08-11  0:00           ` Vladimir Olensky
1999-08-13  0:00             ` Robert Dewar
1999-08-13  0:00               ` Brian Rogoff
1999-08-15  0:00               ` Vladimir Olensky
1999-08-15  0:00                 ` Vladimir Olensky
1999-08-13  0:00             ` Gautier
1999-08-11  0:00     ` Ada vs Delphi? Andre Ratel
1999-08-11  0:00       ` Robert Dewar
1999-08-14  0:00         ` Andre Ratel
1999-08-11  0:00       ` Ada vs Component Pascal (was: Ada vs Delphi?) Ted Dennison
1999-08-06  0:00 ` Ada vs Delphi? William Starner
1999-08-06  0:00   ` William Starner
1999-08-07  0:00   ` tmoran
1999-08-07  0:00     ` Aidan Skinner
1999-08-07  0:00       ` Gautier
1999-08-07  0:00 ` Gautier
replies disabled

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