comp.lang.ada
 help / color / mirror / Atom feed
From: "R. Tim Coslet" <R_Tim_Coslet@pacbell.net>
Subject: Re: Let's change semantics of "use type"
Date: Tue, 12 Nov 2002 08:24:15 GMT
Date: 2002-11-12T08:24:15+00:00	[thread overview]
Message-ID: <B9F5F98B.5DE7%R_Tim_Coslet@pacbell.net> (raw)
In-Reply-To: 4519e058.0211110759.3ebbf128@posting.google.com

The only real use I have ever found in Ada95 for rename is when I need to
make repeated references to the same array element in several places in a
block of code. I rename the array element (to tell the compiler to index it
only once) then use the new name in the places in the code that reference
it.

Example:

    declare
        Selected_Item : Some_Typ renames Big_Arrayo_of_Data(x,y,z);
    begin
        if Selected_Item = Special_Value then
            y := Complex_Function(Selected_Item,z);
            ... more code refering to Selected_Item ...
        end if;
        Selected_Item := Fancy_Function(x,i);
    end;

Note: in the above code the change in y does NOT affect the item already
indexed, so Selected_Item still refers to the same item.

-- 
        R. Tim Coslet
        r_tim_coslet@pacbell.net

Technology, n. Domesticated natural phenomena.


> From: dennison@telepath.com (Ted Dennison)
> Organization: http://groups.google.com/
> Newsgroups: comp.lang.ada
> Date: 11 Nov 2002 07:59:47 -0800
> Subject: Re: Let's change semantics of "use type"
> 
> 
> I've done quite a bit of tagged type programming in Ada95, and I have
> *never* used a rename that way. In fact, I don't believe I've used a
> single rename in Ada95 ever...
> 




  reply	other threads:[~2002-11-12  8:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-08  9:20 Let's change semantics of "use type" Victor Porton
2002-11-08 12:01 ` Adrian Hoe
2002-11-08 13:38 ` Robert A Duff
2002-11-08 20:52   ` Randy Brukardt
2002-11-08 18:12 ` Victor Porton
2002-11-09 15:20   ` Robert A Duff
2002-11-11  5:28 ` Victor Porton
2002-11-11 15:22   ` Robert A Duff
2002-11-11 15:59 ` Ted Dennison
2002-11-12  8:24   ` R. Tim Coslet [this message]
2002-11-12 15:39     ` Ted Dennison
2002-11-12 18:18       ` Preben Randhol
2002-11-12 17:29 ` Victor Porton
2002-11-12 17:32 ` Victor Porton
2002-11-18  1:25 ` Richard Riehle
2002-11-19  4:13 ` Victor Porton
replies disabled

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