comp.lang.ada
 help / color / mirror / Atom feed
* Rename Problem
@ 2007-03-06 16:17 Ant
  2007-03-06 16:53 ` Georg Bauhaus
  2007-03-07  3:47 ` Steve
  0 siblings, 2 replies; 6+ messages in thread
From: Ant @ 2007-03-06 16:17 UTC (permalink / raw)


I am trying to rename an array component, but no luck. Is this
possible or am I just doing something wrong?


TYPE message_array IS ARRAY (index) OF signals_record;
msg : message_array;

PACKAGE m1 IS NEW transmit_message (id, type);

msg (1) : signals RENAMES m1.signals_record;


Anthony




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

* Re: Rename Problem
  2007-03-06 16:17 Rename Problem Ant
@ 2007-03-06 16:53 ` Georg Bauhaus
  2007-03-06 21:50   ` Ant
  2007-03-07  3:47 ` Steve
  1 sibling, 1 reply; 6+ messages in thread
From: Georg Bauhaus @ 2007-03-06 16:53 UTC (permalink / raw)


On Tue, 2007-03-06 at 08:17 -0800, Ant wrote:
> I am trying to rename an array component, but no luck. Is this
> possible or am I just doing something wrong?
> 
> 
> TYPE message_array IS ARRAY (index) OF signals_record;
> msg : message_array;
> 
> PACKAGE m1 IS NEW transmit_message (id, type);
                                          ^^^^
"type" is an Ada keyword. What is transmit_message?

> msg (1) : signals RENAMES m1.signals_record;
                            ^^^^^^^^^^^^^^^^^
This is probably a type, if signals_record from above is a type.

If you want to rename a component of msg, msg (1) say,
then the renamed thing is an object. In this case it is
of type signals_record. Not easy to tell without seeing
some more source, preferably compilable.

 ... : signals_record RENAMES msg (1);






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

* Re: Rename Problem
  2007-03-06 16:53 ` Georg Bauhaus
@ 2007-03-06 21:50   ` Ant
  2007-03-06 23:21     ` Adam Beneschan
  2007-03-07  1:11     ` Jeffrey R. Carter
  0 siblings, 2 replies; 6+ messages in thread
From: Ant @ 2007-03-06 21:50 UTC (permalink / raw)


On Mar 6, 9:53 am, Georg Bauhaus <bauh...@futureapps.de> wrote:
> On Tue, 2007-03-06 at 08:17 -0800, Ant wrote:
> > I am trying to rename an array component, but no luck. Is this
> > possible or am I just doing something wrong?
>
> > TYPE message_array IS ARRAY (index) OF signals_record;
> > msg : message_array;
>
> > PACKAGE m1 IS NEW transmit_message (id, type);
>
>                                           ^^^^
> "type" is an Ada keyword. What is transmit_message?
>
> > msg (1) : signals RENAMES m1.signals_record;
>
>                             ^^^^^^^^^^^^^^^^^
> This is probably a type, if signals_record from above is a type.
>
> If you want to rename a component of msg, msg (1) say,
> then the renamed thing is an object. In this case it is
> of type signals_record. Not easy to tell without seeing
> some more source, preferably compilable.
>
>  ... : signals_record RENAMES msg (1);

This test procedure should compile. Sorry for the laziness.

PROCEDURE test IS

   -------------------------------------------
   GENERIC -- receive message --

      id : integer;

      TYPE message_type IS PRIVATE;

   PACKAGE transmit_message IS

      PROCEDURE write;

   END transmit_message;
   -------------------------------------------

 
-----------------------------------------------------------------------------
   PACKAGE BODY transmit_message IS

      PROCEDURE write IS
      BEGIN
         null;
      END write;

   END transmit_message;
 
-----------------------------------------------------------------------------

   -------------------------------------------
   TYPE signals_record IS
      RECORD
         data1 : boolean;
         data2 : boolean;
      END RECORD;

   FOR signals_record USE
      RECORD
         data1 AT 0 RANGE 0 .. 15;
         data2 AT 0 RANGE 16 .. 31;
      END RECORD;
   -------------------------------------------

   SUBTYPE msg_count IS integer RANGE 1 .. 4;
   TYPE message_array IS ARRAY (msg_count) OF signals_record;
   msg : message_array;

   id : integer := 1;

   PACKAGE m1 IS NEW transmit_message (id, signals_record);

   msg (1) : signals RENAMES m1.signals_record;

END test;




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

* Re: Rename Problem
  2007-03-06 21:50   ` Ant
@ 2007-03-06 23:21     ` Adam Beneschan
  2007-03-07  1:11     ` Jeffrey R. Carter
  1 sibling, 0 replies; 6+ messages in thread
From: Adam Beneschan @ 2007-03-06 23:21 UTC (permalink / raw)


On Mar 6, 1:50 pm, "Ant" <yarze...@hotmail.com> wrote:

>
> > If you want to rename a component of msg, msg (1) say,
> > then the renamed thing is an object. In this case it is
> > of type signals_record. Not easy to tell without seeing
> > some more source, preferably compilable.
>
> >  ... : signals_record RENAMES msg (1);
>
> This test procedure should compile. Sorry for the laziness.
>
> PROCEDURE test IS
>
>    -------------------------------------------
>    GENERIC -- receive message --
>
>       id : integer;
>
>       TYPE message_type IS PRIVATE;
>
>    PACKAGE transmit_message IS
>
>       PROCEDURE write;
>
>    END transmit_message;
>    -------------------------------------------
>
> -----------------------------------------------------------------------------
>    PACKAGE BODY transmit_message IS
>
>       PROCEDURE write IS
>       BEGIN
>          null;
>       END write;
>
>    END transmit_message;
>
> -----------------------------------------------------------------------------
>
>    -------------------------------------------
>    TYPE signals_record IS
>       RECORD
>          data1 : boolean;
>          data2 : boolean;
>       END RECORD;
>
>    FOR signals_record USE
>       RECORD
>          data1 AT 0 RANGE 0 .. 15;
>          data2 AT 0 RANGE 16 .. 31;
>       END RECORD;
>    -------------------------------------------
>
>    SUBTYPE msg_count IS integer RANGE 1 .. 4;
>    TYPE message_array IS ARRAY (msg_count) OF signals_record;
>    msg : message_array;
>
>    id : integer := 1;
>
>    PACKAGE m1 IS NEW transmit_message (id, signals_record);
>
>    msg (1) : signals RENAMES m1.signals_record;
>
> END test;

That RENAMES is wrong on so many levels, I don't know where to begin.
Transmit_Message doesn't declare a "signals_record" so
m1.signals_record doesn't exist; "signals_record" is a type, anyway,
and you can't rename a type; the identifier "signals" isn't declared
and it has no meaning; and you can't use RENAMES to declare an
identifier you've already declared (i.e. "msg"), and you can't use
RENAMES to declare an array component anyway.

I can't tell what you're trying to accomplish.  What were you trying
to do with this RENAMES declaration?  If you can describe that, we can
help you write it correctly.  If all you're doing is to try to give
another name to msg(1), so you can call it something else, such as
msg_1, then Georg already gave you the answer:

   msg_1 : signals_record renames msg(1);

                               -- Adam








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

* Re: Rename Problem
  2007-03-06 21:50   ` Ant
  2007-03-06 23:21     ` Adam Beneschan
@ 2007-03-07  1:11     ` Jeffrey R. Carter
  1 sibling, 0 replies; 6+ messages in thread
From: Jeffrey R. Carter @ 2007-03-07  1:11 UTC (permalink / raw)


Ant wrote:
> 
> This test procedure should compile. Sorry for the laziness.

No, it won't.

>    GENERIC -- receive message --
> 
>       id : integer;
> 
>       TYPE message_type IS PRIVATE;
> 
>    PACKAGE transmit_message IS
> 
>       PROCEDURE write;
> 
>    END transmit_message;

>    PACKAGE m1 IS NEW transmit_message (id, signals_record);
> 
>    msg (1) : signals RENAMES m1.signals_record;

There's nothing in M1 named Signals_Record.

-- 
Jeff Carter
"When danger reared its ugly head, he bravely
turned his tail and fled."
Monty Python and the Holy Grail
60



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

* Re: Rename Problem
  2007-03-06 16:17 Rename Problem Ant
  2007-03-06 16:53 ` Georg Bauhaus
@ 2007-03-07  3:47 ` Steve
  1 sibling, 0 replies; 6+ messages in thread
From: Steve @ 2007-03-07  3:47 UTC (permalink / raw)


"Ant" <yarzepol@hotmail.com> wrote in message 
news:1173197839.773371.261080@q40g2000cwq.googlegroups.com...
>I am trying to rename an array component, but no luck. Is this
> possible or am I just doing something wrong?
>

Here is an example of renaming an array component:

procedure Rename_Example is

  type index is range 1 .. 10;

  type Signals_Record is
    record
      junk : Integer;
    end record;

  type Message_Array is array( index ) of Signals_Record;

  msg  : Message_Array;
  msg1 : Signals_Record renames msg( 1 );

begin
  null;
end Rename_Example;

This is a complete example that compiles.  It may or may not do what you 
were attempting to do, since that is unclear from your example.

In the future please include a COMPLETE minimal example that may be 
compiled, or that you are attempting to compile.  There are a lot of helpful 
people that follow this newsgroup that are more than happy to help.

Regards,
Steve
(The Duck)

>
> TYPE message_array IS ARRAY (index) OF signals_record;
> msg : message_array;
>
> PACKAGE m1 IS NEW transmit_message (id, type);
>
> msg (1) : signals RENAMES m1.signals_record;
>
>
> Anthony
> 





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

end of thread, other threads:[~2007-03-07  3:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-06 16:17 Rename Problem Ant
2007-03-06 16:53 ` Georg Bauhaus
2007-03-06 21:50   ` Ant
2007-03-06 23:21     ` Adam Beneschan
2007-03-07  1:11     ` Jeffrey R. Carter
2007-03-07  3:47 ` Steve

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