comp.lang.ada
 help / color / mirror / Atom feed
* "constant X renames" (language-lawyers)
@ 1996-12-11  0:00 W. Wesley Groleau (Wes)
  1996-12-13  0:00 ` Robert A Duff
  1996-12-13  0:00 ` Vincent Marciante
  0 siblings, 2 replies; 3+ messages in thread
From: W. Wesley Groleau (Wes) @ 1996-12-11  0:00 UTC (permalink / raw)



procedure Proc ( Stupid_Name : in Param_Type ) is

  Sensible_Name : constant Param_Type renames Stupid_Name;

--------------------
This is illegal by LRM 83 8.5 (2) and LRM 95 8.5.1 (2) because "constant"
is not part of a (sub)type mark.  The restriction makes sense in a way,
since the item is already a constant and if it weren't we still can't
change its properties by renaming.  Still, it surprised me after
nearly ten years of Ada programming.  (I wouldn't have even tried it if
my predecessor had used a better name.)

Was this "feature" planned, or just an accident/side-effect?  There is no
specific language about it to indicate it was thought of.  In fact, the
BNF for "(sub)type_mark in section three is the only thing I can find that
makes it illegal--section eight says renaming will not change whether it
is or isn't constant, but doesn't come right out and prohibit calling it
constant.

"constant" has documentation value in this case.
One might also imagine a case where for documentation purposes one wants
the new view to never have assignments even though the old is assignable.

On the other hand, allowing "constant" might make a programmer think that
a renames without the keyword is assignable--which may not true.

-----------------------------------------------------------------------------
W. Wesley Groleau (Wes)    wwgrol    x4923    MS 10-40    10C2C6    AFATDS IG
-----------------------------------------------------------------------------




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

* Re: "constant X renames" (language-lawyers)
  1996-12-11  0:00 "constant X renames" (language-lawyers) W. Wesley Groleau (Wes)
@ 1996-12-13  0:00 ` Robert A Duff
  1996-12-13  0:00 ` Vincent Marciante
  1 sibling, 0 replies; 3+ messages in thread
From: Robert A Duff @ 1996-12-13  0:00 UTC (permalink / raw)



In article <9612111834.AA12317@most>,
W. Wesley Groleau (Wes) <wwgrol@PSESERV3.FW.HAC.COM> wrote:
>Was this "feature" planned, or just an accident/side-effect?  There is no
>specific language about it to indicate it was thought of.

8.5.1(6) makes it pretty clear that this is an intended "feature".
Yeah, it's kind of strange.  It might make more sense if renamings had
to declare what they are, and have it checked that you said it right.
The following is particularly confusing:

    X: Integer := 99;
    subtype S is Integer range 1..10;
    Y: S renames X;

since the range 1..10 is completely ignored.

- Bob




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

* Re: "constant X renames" (language-lawyers)
  1996-12-11  0:00 "constant X renames" (language-lawyers) W. Wesley Groleau (Wes)
  1996-12-13  0:00 ` Robert A Duff
@ 1996-12-13  0:00 ` Vincent Marciante
  1 sibling, 0 replies; 3+ messages in thread
From: Vincent Marciante @ 1996-12-13  0:00 UTC (permalink / raw)



Just leave out "constant" the renaming will work.

I sometimes rename subprogram parameters in the body by design; It is a
way to choose a parameter name that makes a call of the subprogram
readable yet also use a name in the body that makes the implementation
more readable.  That way the name that is the best from the particular 
point view can be used!


procedure Get (The_Value                 : out Value;
               After_Checking_The_Source : in  Source) is

  The_Source : Source renames After_Checking_The_Source; 

begin
  if The_Source = ...
     The_Value := ...   
  else
     ...
  end if; 
end Copy;

 W. Wesley Groleau (Wes) (wwgrol@PSESERV3.FW.HAC.COM) wrote:
: procedure Proc ( Stupid_Name : in Param_Type ) is

:   Sensible_Name : constant Param_Type renames Stupid_Name;

: --------------------
: This is illegal by LRM 83 8.5 (2) and LRM 95 8.5.1 (2) because "constant"
: is not part of a (sub)type mark.  The restriction makes sense in a way,
: since the item is already a constant and if it weren't we still can't
: change its properties by renaming.  Still, it surprised me after
: nearly ten years of Ada programming.  (I wouldn't have even tried it if
: my predecessor had used a better name.)





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

end of thread, other threads:[~1996-12-13  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-12-11  0:00 "constant X renames" (language-lawyers) W. Wesley Groleau (Wes)
1996-12-13  0:00 ` Robert A Duff
1996-12-13  0:00 ` Vincent Marciante

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