comp.lang.ada
 help / color / mirror / Atom feed
* Re: Accessibility levels, continued
  1999-02-05  0:00 Accessibility levels, continued adam
  1999-02-05  0:00 ` Robert A Duff
  1999-02-05  0:00 ` adam
@ 1999-02-05  0:00 ` Tucker Taft
  2 siblings, 0 replies; 4+ messages in thread
From: Tucker Taft @ 1999-02-05  0:00 UTC (permalink / raw)


adam@irvine.com wrote:
> 
> Should this program raise an exception?

No.  The "accessibility level" of Var passes through the
two calls with access parameters, meaning that your line marked
[1] is equivalent to "Acc_Var := Var'access;" as far
as accessibility checking, with the difference that the check is
performed at run-time rather than compile-time.
 
>     procedure Test is
> 
>         type T is record
>             Field : Integer;
>         end record;
> 
>         Var : T;
> 
>         type Access_T is access T;
>         Acc_Var : Access_T;
> 
>         procedure Outer (Outer_Param : access T) is
> 
>             procedure Inner (Inner_Param : access T) is
>             begin
>                 Acc_Var := Inner_Param.all'access; -- [1]
>             end Inner;
> 
>         begin
>             Inner (Outer_Param);
>         end Outer;
> 
>     begin
>         Outer (Var'access);                        -- [2]
>     end Test;
> 
> It doesn't look like it should, if you follow the intent of the
> accessibility rules in 3.10.2.  Acc_Var will be assigned to an access
> to Var, and since Acc_Var's type does not have a deeper accessibility
> level than Var, everything should be fine.  However, I believe that
> the way the RM is written, the program should raise Program_Error at
> line [1].  Here's what seems to be going on:
> 
> 3.10.2(29): 'ACCESS will succeed as long as the accessibility level of
> Inner_Param.all is not deeper than that of Access_T.
> 
> 3.10.2(15): The accessibility level of Inner_Param.all equals that of
> Inner_Param's type, which is an anonymous access type.
> 
> 3.10.2(13): The accessibility level of Inner_Param's anonymous access
> type is the same as that of the view designated by the actual, in this
> case Outer_Param.
> 
> I don't know the exact meaning of the "view designated by the actual"
> when the actual is another parameter.  I haven't found any reason to
> believe that the last clause of the above paragraph is different from,
> more simply, "the accessibility level of Outer_Param". 

No, it is the accessibility level of the object *designated* by
Outer_Param.  Remember that "designated" by is the same as
"pointed-to" by.  Ada mantra: "Pointers point, access values designate,
names denote."

> ... Which leads
> us to:
> 
> 3.10.2(7): Since Outer_Param is a parameter, the accessibility level
> of Outer_Param is the same as its master, Outer.

If you had written Outer_Param'Access, then you would be 
interested in the accessibility level of Outer_Param itself.
But if you just write Outer_Param, you are interested in 
the accessibility level of the thing it points at (Outer_Param.all).
"Access parameters" (aka parameters of an anonymous access type)
are unique in that they "carry" along at run-time the accessibility
level of the thing they point at (their designated object). 


> Stringing everything together, the accessibility level of
> Inner_Param.all'access is the same as that of Outer; and since the
> accessibility level of Outer is deeper than that of Access_T, the
> program should raise a Program_Error.

Nope.  The accessibility level of Inner_Param.all is the same
as that of Outer_param.all, which is the same as Var.

> Is this the right interpretation?  Or did I miss something?

You missed (no William Tell award today ;-).

>                                 -- thanks, Adam

-Tuck
-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




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

* Re: Accessibility levels, continued
  1999-02-05  0:00 Accessibility levels, continued adam
  1999-02-05  0:00 ` Robert A Duff
@ 1999-02-05  0:00 ` adam
  1999-02-05  0:00 ` Tucker Taft
  2 siblings, 0 replies; 4+ messages in thread
From: adam @ 1999-02-05  0:00 UTC (permalink / raw)


In article <79dse1$ut4$1@nnrp1.dejanews.com>, I scribbled:

. . .
> 3.10.2(13): The accessibility level of Inner_Param's anonymous access
> type is the same as that of the view designated by the actual, in this
> case Outer_Param.
>
> I don't know the exact meaning of the "view designated by the actual"
> when the actual is another parameter.  I haven't found any reason to
> believe that the last clause of the above paragraph is different from,
> more simply, "the accessibility level of Outer_Param".  Which leads
> us to:

Aaaaugh, I blew this one too.  It didn't occur to me while I was reading
the text that "designate" had a technical meaning other than just being
an English word.  It's defined in 3.10(1), so "view designated by the
actual" actually means "the thing that the actual parameter points to."
That makes more sense.

I miss the cross-references that used to occur at the end of every section
in the Ada 83 manual.  Those references would have included the word
"designate", and that would have tipped me off that I would need to look
up what the word meant in this context.  Meanwhile, I'm 0 for 2, tripped up
both times on words beginning with "d".  Time to start boning up on some of
the other basic concepts of the language: declarative region, dispatching,
discriminant, dynamic binding . . .

				-- Adam

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




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

* Re: Accessibility levels, continued
  1999-02-05  0:00 Accessibility levels, continued adam
@ 1999-02-05  0:00 ` Robert A Duff
  1999-02-05  0:00 ` adam
  1999-02-05  0:00 ` Tucker Taft
  2 siblings, 0 replies; 4+ messages in thread
From: Robert A Duff @ 1999-02-05  0:00 UTC (permalink / raw)


adam@irvine.com writes:

> Should this program raise an exception?

It's illegal (ie compile-time error).  ;-)

(OK, sorry for being a smart-aleck.  If you fix the compile-time error,
it should not raise an exception.)

>     procedure Test is
> 
>         type T is record
>             Field : Integer;
>         end record;
> 
>         Var : T;
> 
>         type Access_T is access T;
>         Acc_Var : Access_T;
> 
>         procedure Outer (Outer_Param : access T) is
> 
>             procedure Inner (Inner_Param : access T) is
>             begin
>                 Acc_Var := Inner_Param.all'access; -- [1]
>             end Inner;
> 
>         begin
>             Inner (Outer_Param);
>         end Outer;
> 
>     begin
>         Outer (Var'access);                        -- [2]
>     end Test;
> 
> It doesn't look like it should, if you follow the intent of the
> accessibility rules in 3.10.2.  Acc_Var will be assigned to an access
> to Var, and since Acc_Var's type does not have a deeper accessibility
> level than Var, everything should be fine.

Right.

>...However, I believe that
> the way the RM is written, the program should raise Program_Error at
> line [1].  Here's what seems to be going on:
> 
> 3.10.2(29): 'ACCESS will succeed as long as the accessibility level of
> Inner_Param.all is not deeper than that of Access_T.
> 
> 3.10.2(15): The accessibility level of Inner_Param.all equals that of
> Inner_Param's type, which is an anonymous access type.
> 
> 3.10.2(13): The accessibility level of Inner_Param's anonymous access
> type is the same as that of the view designated by the actual, in this
> case Outer_Param.

So far, so good.

> I don't know the exact meaning of the "view designated by the actual"
> when the actual is another parameter.  I haven't found any reason to
> believe that the last clause of the above paragraph is different from,
> more simply, "the accessibility level of Outer_Param".

"Designated" means the thing it points to.  It's not the same thing as
"denoted".  The actual is Outer_Param; the designated object is
Outer_Param.all.  So you then invoke the same paragraphs you mentioned
above, again.  So you end up with the accessibility level of Var, which
is the *same* as Access_T, so all is well.

- Bob
-- 
Change robert to bob to get my real email address.  Sorry.




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

* Accessibility levels, continued
@ 1999-02-05  0:00 adam
  1999-02-05  0:00 ` Robert A Duff
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: adam @ 1999-02-05  0:00 UTC (permalink / raw)


Should this program raise an exception?

    procedure Test is

        type T is record
            Field : Integer;
        end record;

        Var : T;

        type Access_T is access T;
        Acc_Var : Access_T;

        procedure Outer (Outer_Param : access T) is

            procedure Inner (Inner_Param : access T) is
            begin
                Acc_Var := Inner_Param.all'access; -- [1]
            end Inner;

        begin
            Inner (Outer_Param);
        end Outer;

    begin
        Outer (Var'access);                        -- [2]
    end Test;

It doesn't look like it should, if you follow the intent of the
accessibility rules in 3.10.2.  Acc_Var will be assigned to an access
to Var, and since Acc_Var's type does not have a deeper accessibility
level than Var, everything should be fine.  However, I believe that
the way the RM is written, the program should raise Program_Error at
line [1].  Here's what seems to be going on:

3.10.2(29): 'ACCESS will succeed as long as the accessibility level of
Inner_Param.all is not deeper than that of Access_T.

3.10.2(15): The accessibility level of Inner_Param.all equals that of
Inner_Param's type, which is an anonymous access type.

3.10.2(13): The accessibility level of Inner_Param's anonymous access
type is the same as that of the view designated by the actual, in this
case Outer_Param.

I don't know the exact meaning of the "view designated by the actual"
when the actual is another parameter.  I haven't found any reason to
believe that the last clause of the above paragraph is different from,
more simply, "the accessibility level of Outer_Param".  Which leads
us to:

3.10.2(7): Since Outer_Param is a parameter, the accessibility level
of Outer_Param is the same as its master, Outer.

Stringing everything together, the accessibility level of
Inner_Param.all'access is the same as that of Outer; and since the
accessibility level of Outer is deeper than that of Access_T, the
program should raise a Program_Error.

Is this the right interpretation?  Or did I miss something?

                                -- thanks, Adam

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




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

end of thread, other threads:[~1999-02-05  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-05  0:00 Accessibility levels, continued adam
1999-02-05  0:00 ` Robert A Duff
1999-02-05  0:00 ` adam
1999-02-05  0:00 ` Tucker Taft

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