comp.lang.ada
 help / color / mirror / Atom feed
* Limited Type Access
@ 2001-10-29 16:08 ANH_VO
  2001-10-29 18:19 ` Mark Lundquist
  2001-10-29 19:16 ` Matthew Heaney
  0 siblings, 2 replies; 5+ messages in thread
From: ANH_VO @ 2001-10-29 16:08 UTC (permalink / raw)
  To: comp.lang.ada

Greeting,

I could not figure out why the codes below compiled without any error. My
thought was that access type of a limited type is considered limited. Therefore,
Object type must be limited because its component is limited. What did I miss?
Thanks for your help.

Anh Vo

package Limited_Access is

   protected type Counting ( Start_Count : Positive := 1) is
      entry Secure;
      procedure Release;
      
   private
      Current_Count : Natural := Start_Count;
   end Counting;
   
   subtype Binary is Counting (Start_Count => 1);
   
   type Binary_Access is access all Binary;
   
   type Object is 
      record
         Sem : Binary_Access;
      end record;

end Limited_Access;



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

* Re: Limited Type Access
  2001-10-29 16:08 ANH_VO
@ 2001-10-29 18:19 ` Mark Lundquist
  2001-10-29 19:16 ` Matthew Heaney
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Lundquist @ 2001-10-29 18:19 UTC (permalink / raw)


Hi Anh,

<ANH_VO@udlp.com> wrote in message
news:mailman.1004379225.31568.comp.lang.ada@ada.eu.org...
> Greeting,
>
> I could not figure out why the codes below compiled without any error. My
> thought was that access type of a limited type is considered limited.

Nope... not true!

-- Mark






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

* RE: Limited Type Access
@ 2001-10-29 18:27 Beard, Frank
  2001-10-29 23:59 ` Mark Lundquist
  0 siblings, 1 reply; 5+ messages in thread
From: Beard, Frank @ 2001-10-29 18:27 UTC (permalink / raw)
  To: 'comp.lang.ada@ada.eu.org'

There is no limited type declared below.  You named your package
Limited_Access, but that doesn't make anything limited.  It's just
a name in this case.  You have to declare the type as limited.

There was a feature in Ada 83 that carries over to Ada 95.  You
couldn't pass a limited type object around, but you could pass
a pointer to the limited type object.

Frank

-----Original Message-----
From: ANH_VO@udlp.com [mailto:ANH_VO@udlp.com]
Sent: Monday, October 29, 2001 11:09 AM
To: comp.lang.ada@ada.eu.org
Subject: Limited Type Access


Greeting,

I could not figure out why the codes below compiled without any error. My
thought was that access type of a limited type is considered limited.
Therefore,
Object type must be limited because its component is limited. What did I
miss?
Thanks for your help.

Anh Vo

package Limited_Access is

   protected type Counting ( Start_Count : Positive := 1) is
      entry Secure;
      procedure Release;
      
   private
      Current_Count : Natural := Start_Count;
   end Counting;
   
   subtype Binary is Counting (Start_Count => 1);
   
   type Binary_Access is access all Binary;
   
   type Object is 
      record
         Sem : Binary_Access;
      end record;

end Limited_Access;
_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada



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

* Re: Limited Type Access
  2001-10-29 16:08 ANH_VO
  2001-10-29 18:19 ` Mark Lundquist
@ 2001-10-29 19:16 ` Matthew Heaney
  1 sibling, 0 replies; 5+ messages in thread
From: Matthew Heaney @ 2001-10-29 19:16 UTC (permalink / raw)



<ANH_VO@udlp.com> wrote in message
news:mailman.1004379225.31568.comp.lang.ada@ada.eu.org...
> Greeting,
>
> I could not figure out why the codes below compiled without any error. My
> thought was that access type of a limited type is considered limited.

You may be confusing access types with array (really, "composite") types.
An array type whose component type is limited is itself limited.

An access type is always nonlimited, irrespective of the limitedness of the
designated type.

> Therefore,
> Object type must be limited because its component is limited. What did I
miss?

A record type containing a limited component is itself limited -- just like
for arrays.  A record type containing with only nonlimited components is
nonlimited.  However, in either case you are of course free to explicitly
declare a record type as limited:

    type Object is
       limited record
          Sem : Binary_Access;
       end record;


One of Bob Duff's ideas was to be able to declare array types as limited,
like this:

   type Limited_Array is limited array (Positive range <>) of Integer;
  --not legal Ada syntax









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

* Re: Limited Type Access
  2001-10-29 18:27 Limited Type Access Beard, Frank
@ 2001-10-29 23:59 ` Mark Lundquist
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Lundquist @ 2001-10-29 23:59 UTC (permalink / raw)



"Beard, Frank" <beardf@spawar.navy.mil> wrote in message
news:mailman.1004380133.32206.comp.lang.ada@ada.eu.org...
> There is no limited type declared below.  You named your package
> Limited_Access, but that doesn't make anything limited.  It's just
> a name in this case.  You have to declare the type as limited.

The limited type he declared was the protected type.  All protected types
are limited.

-- mark






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

end of thread, other threads:[~2001-10-29 23:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-29 18:27 Limited Type Access Beard, Frank
2001-10-29 23:59 ` Mark Lundquist
  -- strict thread matches above, loose matches on Subject: below --
2001-10-29 16:08 ANH_VO
2001-10-29 18:19 ` Mark Lundquist
2001-10-29 19:16 ` Matthew Heaney

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