comp.lang.ada
 help / color / mirror / Atom feed
* Renaming subprogram and default_expression
@ 2002-02-14 10:51 Florian Weimer
  2002-02-14 11:31 ` sk
  0 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2002-02-14 10:51 UTC (permalink / raw)


Is anything wrong with the following program?  Maybe I'm just
confused, but it looks perfectly legal to me.

procedure Defaults is

   type Typ is new Integer;

   procedure Original (X : Typ);
   procedure Renamed (X : Typ := -1);
   
   procedure Renamed (X : Typ := -1)
     renames Original;
   
   procedure Original (X : Typ) is
   begin
      null;
   end Original;

begin
   null;
end Defaults;



^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: Renaming subprogram and default_expression
@ 2002-02-14 11:52 Christoph Grein
  2002-02-14 12:04 ` Florian Weimer
  0 siblings, 1 reply; 15+ messages in thread
From: Christoph Grein @ 2002-02-14 11:52 UTC (permalink / raw)


> From: Florian Weimer <fw@deneb.enyo.de>
> 
> Is anything wrong with the following program?  Maybe I'm just
> confused, but it looks perfectly legal to me.
> 
> procedure Defaults is
> 
>    type Typ is new Integer;
> 
>    procedure Original (X : Typ);        <--- declaration
>    procedure Renamed (X : Typ := -1);   <--- declaration
>    
>    procedure Renamed (X : Typ := -1)    <--- renaming as body
>      renames Original;
>    
>    procedure Original (X : Typ) is      <--- proper body
>    begin
>       null;
>    end Original;
> 
> begin
>    null;
> end Defaults;

So it looks OK. Did some compiler complain?



^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: Renaming subprogram and default_expression
@ 2002-02-15  5:38 Christoph Grein
  0 siblings, 0 replies; 15+ messages in thread
From: Christoph Grein @ 2002-02-15  5:38 UTC (permalink / raw)


> package Defaults is
> 
>    procedure Original (X : Integer);        <--- (1) declaration
>    procedure Renamed (X : Integer := -1);   <--- (2) declaration
> 
> private
> 
>    procedure Renamed (X : Integer := -1)    <--- (3) renaming declaration
>      renames Original;
>      
> end Defaults;
> 
> the declaration is needed, and you get the error.  Looks like a bug.

The above exegesis is wrong. There is no bog here, the compiler is correct.
The following is the original. Please note the difference. While (3) is a 
renaming declaration that is illegal at this place because there is a 
conflictiog declaration (2), (3') is a renaming as body, completing the 
declaration (2'). If you remove (2'), (3') becomes a renaming declaration.

>    type Typ is new Integer;
> 
>    procedure Original (X : Typ);        <--- (1') declaration
>    procedure Renamed (X : Typ := -1);   <--- (2') declaration
>    
>    procedure Renamed (X : Typ := -1)    <--- (3') renaming as body
>      renames Original;
>    
>    procedure Original (X : Typ) is      <--- proper body
>    begin
>       null;
>    end Original;
> 
> begin
>    null;
> end Defaults;



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2002-02-15  8:40 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-14 10:51 Renaming subprogram and default_expression Florian Weimer
2002-02-14 11:31 ` sk
  -- strict thread matches above, loose matches on Subject: below --
2002-02-14 11:52 Christoph Grein
2002-02-14 12:04 ` Florian Weimer
2002-02-14 12:46   ` Lutz Donnerhacke
2002-02-14 13:15     ` Florian Weimer
2002-02-14 14:01   ` Alexander Boucke
2002-02-14 15:18     ` Florian Weimer
2002-02-14 15:46       ` Alexander Boucke
2002-02-14 15:58         ` Florian Weimer
2002-02-14 16:24           ` Alexander Boucke
2002-02-14 16:31           ` Larry Hazel
2002-02-14 16:35           ` Florian Weimer
2002-02-15  8:40             ` Lutz Donnerhacke
2002-02-15  5:38 Christoph Grein

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