Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The meek shall inherit the earth; the rest of us, the Universe.


devel / comp.lang.ada / Equivalence between named access and anonymous access.

SubjectAuthor
* Equivalence between named access and anonymous access.Blady
+* Re: Equivalence between named access and anonymous access.Dmitry A. Kazakov
|`* Re: Equivalence between named access and anonymous access.Blady
| +* Re: Equivalence between named access and anonymous access.Jeffrey R.Carter
| |`- Re: Equivalence between named access and anonymous access.Blady
| `- Re: Equivalence between named access and anonymous access.Dmitry A. Kazakov
+- Re: Equivalence between named access and anonymous access.Gautier write-only address
`- Re: Equivalence between named access and anonymous access.Jeffrey R.Carter

1
Equivalence between named access and anonymous access.

<uda2ql$2hle9$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10004&group=comp.lang.ada#10004

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: p.p11@orange.fr (Blady)
Newsgroups: comp.lang.ada
Subject: Equivalence between named access and anonymous access.
Date: Wed, 6 Sep 2023 16:37:08 +0200
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <uda2ql$2hle9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 6 Sep 2023 14:37:09 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="670427d81b15799f52a4c075a72b6b70";
logging-data="2676169"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/JPKQJi3Ov+KZVdrsLxqSw"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.13.0
Cancel-Lock: sha1:RS8KjLfSbLeoU111w2VOnht8zGc=
Content-Language: en-US
 by: Blady - Wed, 6 Sep 2023 14:37 UTC

Hello,

I'm wondering about named access and anonymous access.
In the following Ada code, are the writing of parameter P1 type of
procedures PA and PB equivalent ?

package C1 is
type Inst is tagged null record;
type Class is access all Inst'Class;
end C1;

with C1;
package C2 is
type Inst is tagged null record;
type Class is access all Inst'Class;

procedure PA (Self : Inst; P1 : C1.Class); -- named access
procedure PB (Self : Inst; P1 : access C1.Inst'Class); -- anonymous
access
end C2;

Same with:
function FA (Self : Inst) return C1.Class; -- named access
function FB (Self : Inst) return access C1.Inst'Class; -- anonymous
access

Are FA and FB writing equivalent?
If not why?

Thanks, Pascal.

Re: Equivalence between named access and anonymous access.

<uda7c1$2ids2$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10006&group=comp.lang.ada#10006

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Equivalence between named access and anonymous access.
Date: Wed, 6 Sep 2023 17:54:42 +0200
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <uda7c1$2ids2$1@dont-email.me>
References: <uda2ql$2hle9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 6 Sep 2023 15:54:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="45219ce80d83fc0bae96dda1999b3d4d";
logging-data="2701186"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jrDjgP2Se7fbqmpcm8wEF1QkHdfBA9xM="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.0
Cancel-Lock: sha1:R5TU5Yx31LTivCz/p6P0g/Gu7dk=
Content-Language: en-US
In-Reply-To: <uda2ql$2hle9$1@dont-email.me>
 by: Dmitry A. Kazakov - Wed, 6 Sep 2023 15:54 UTC

On 2023-09-06 16:37, Blady wrote:

> I'm wondering about named access and anonymous access.
> In the following Ada code, are the writing of parameter P1 type of
> procedures PA and PB equivalent ?
>
> package C1 is
>   type Inst is tagged null record;
>   type Class is access all Inst'Class;
> end C1;
>
> with C1;
> package C2 is
>   type Inst is tagged null record;
>   type Class is access all Inst'Class;
>
>   procedure PA (Self : Inst; P1 : C1.Class); -- named access
>   procedure PB (Self : Inst; P1 : access C1.Inst'Class); -- anonymous
> access
> end C2;
>
> Same with:
>   function FA (Self : Inst) return C1.Class; -- named access
>   function FB (Self : Inst) return access C1.Inst'Class; -- anonymous
> access
>
> Are FA and FB writing equivalent?
> If not why?

They are not equivalent from the access checks point of view:

declare
Y : C2.Inst;
X : aliased C1.Inst;
begin
C2.PA (Y, X'Access); -- Non-local pointer error
C2.PB (Y, X'Access); -- Fine
end;

Furthermore, tagged anonymous access is controlling (dispatches) when
not class-wide.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Equivalence between named access and anonymous access.

<8aec1f64-32e8-4815-8676-dc41ce353e3fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10008&group=comp.lang.ada#10008

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:9048:b0:76f:2990:2d88 with SMTP id rl8-20020a05620a904800b0076f29902d88mr308948qkn.9.1694033703066;
Wed, 06 Sep 2023 13:55:03 -0700 (PDT)
X-Received: by 2002:a63:3c4a:0:b0:570:26e:1606 with SMTP id
i10-20020a633c4a000000b00570026e1606mr3522062pgn.2.1694033702655; Wed, 06 Sep
2023 13:55:02 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!tncsrv06.tnetconsulting.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 6 Sep 2023 13:55:02 -0700 (PDT)
In-Reply-To: <uda2ql$2hle9$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a02:1210:2e90:8100:88f4:a68c:e354:e61;
posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG
NNTP-Posting-Host: 2a02:1210:2e90:8100:88f4:a68c:e354:e61
References: <uda2ql$2hle9$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8aec1f64-32e8-4815-8676-dc41ce353e3fn@googlegroups.com>
Subject: Re: Equivalence between named access and anonymous access.
From: gautier_niouzes@hotmail.com (Gautier write-only address)
Injection-Date: Wed, 06 Sep 2023 20:55:03 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1736
 by: Gautier write-only a - Wed, 6 Sep 2023 20:55 UTC

> In the following Ada code, are the writing of parameter P1 type of
> procedures PA and PB equivalent ?

They are not equivalent because the anonymous access opens more possibilities (example below), but you are certainly aware of that.
So I guess you have another question in mind...

with C1, C2;

procedure test is
x2 : C2.Inst;
type My_Reference_1 is access all C1.Inst'Class;
r1 : My_Reference_1;
begin
x2.PB (r1);
x2.PA (r1);
-- ^ expected type "Class" defined at c1.ads:3
-- found type "My_Reference_1" defined at line 6
end;

Re: Equivalence between named access and anonymous access.

<udb4vi$2jl81$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10010&group=comp.lang.ada#10010

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Equivalence between named access and anonymous access.
Date: Thu, 7 Sep 2023 02:20:02 +0200
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <udb4vi$2jl81$1@dont-email.me>
References: <uda2ql$2hle9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 7 Sep 2023 00:20:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3de256addc8fe2de40e10a2bd4df6531";
logging-data="2741505"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/PNg1MkeYzfm1umE7yy8AZWdJm+aY0WE4="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.15.0
Cancel-Lock: sha1:X0BtCsJG6jm1u1HUgkSKFulkL6E=
In-Reply-To: <uda2ql$2hle9$1@dont-email.me>
Content-Language: en-US
 by: Jeffrey R.Carter - Thu, 7 Sep 2023 00:20 UTC

On 2023-09-06 16:37, Blady wrote:
>
> I'm wondering about named access and anonymous access.

The rules for using access-to-object types are

1. Don't use access types
2. If you think you should use access types, see rule 1.
3. If you still think you should use access types, don't use anonymous access types
4. If you still think you should use anonymous access types, don't develop software

The semantics of named access types are well defined and easily understood. The
semantics of anonymous access types are defined in ARM 3.10.2, of which the AARM
says

"Subclause 3.10.2, home of the accessibility rules, is informally known as the
'Heart of Darkness' amongst the maintainers of Ada. Woe unto all who enter here
(well, at least unto anyone that needs to understand any of these rules)."

The ARG freely admits that no one understands 3.10.2, which means that what you
get when you use anonymous access types is whatever the compiler writer thinks
it says. This may differ between compilers and between different versions of the
same compiler, and from what you think it says.

So no sane person uses them.

--
Jeff Carter
“Companies who create critical applications—those
with a low tolerance for risk—would do well to use
Ada for those applications, even if they're more
familiar with other languages like C and C++.”
Mike Jelks
207

Re: Equivalence between named access and anonymous access.

<udcsdo$31uib$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10015&group=comp.lang.ada#10015

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: p.p11@orange.fr (Blady)
Newsgroups: comp.lang.ada
Subject: Re: Equivalence between named access and anonymous access.
Date: Thu, 7 Sep 2023 18:06:15 +0200
Organization: A noiseless patient Spider
Lines: 88
Message-ID: <udcsdo$31uib$1@dont-email.me>
References: <uda2ql$2hle9$1@dont-email.me> <uda7c1$2ids2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 7 Sep 2023 16:06:17 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4eed53ccae3c2f0e3aa01f2971e54c1e";
logging-data="3209803"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ZkCSlUvC6iqo/rTUUHDIP"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.13.0
Cancel-Lock: sha1:+MJ/4gZQvhgb8xg+42wNk+KhCCY=
In-Reply-To: <uda7c1$2ids2$1@dont-email.me>
Content-Language: en-US
 by: Blady - Thu, 7 Sep 2023 16:06 UTC

Le 06/09/2023 à 17:54, Dmitry A. Kazakov a écrit :
> On 2023-09-06 16:37, Blady wrote:
>
>> I'm wondering about named access and anonymous access.
>> In the following Ada code, are the writing of parameter P1 type of
>> procedures PA and PB equivalent ?
>>
>> package C1 is
>>    type Inst is tagged null record;
>>    type Class is access all Inst'Class;
>> end C1;
>>
>> with C1;
>> package C2 is
>>    type Inst is tagged null record;
>>    type Class is access all Inst'Class;
>>
>>    procedure PA (Self : Inst; P1 : C1.Class); -- named access
>>    procedure PB (Self : Inst; P1 : access C1.Inst'Class); -- anonymous
>> access
>> end C2;
>>
>> Same with:
>>    function FA (Self : Inst) return C1.Class; -- named access
>>    function FB (Self : Inst) return access C1.Inst'Class; -- anonymous
>> access
>>
>> Are FA and FB writing equivalent?
>> If not why?
>
> They are not equivalent from the access checks point of view:
>
>    declare
>       Y : C2.Inst;
>       X : aliased C1.Inst;
>    begin
>       C2.PA (Y, X'Access); -- Non-local pointer error
>       C2.PB (Y, X'Access); -- Fine
>    end;
>
> Furthermore, tagged anonymous access is controlling (dispatches) when
> not class-wide.
>

Thanks Dmitry, also Gautier and Jeff for your previous answers,

Well, I was questioning myself about the choice between named access and
anonymous access in the old Ada port of Java library, for instance:

type Typ;
type Ref is access all Typ'Class;
type Typ(LayoutManager2_I : Java.Awt.LayoutManager2.Ref;
Serializable_I : Java.Io.Serializable.Ref)
is new Java.Lang.Object.Typ
with null record;
------------------------------
-- Constructor Declarations --
------------------------------
function New_BorderLayout (This : Ref := null)
return Ref;

function New_BorderLayout (P1_Int : Java.Int;
P2_Int : Java.Int;
This : Ref := null)
return Ref;
-------------------------
-- Method Declarations --
-------------------------
procedure AddLayoutComponent (This : access Typ;
P1_Component : access
Standard.Java.Awt.Component.Typ'Class;
P2_Object : access
Standard.Java.Lang.Object.Typ'Class);
function GetLayoutComponent (This : access Typ;
P1_Object : access
Standard.Java.Lang.Object.Typ'Class)
return access Java.Awt.Component.Typ'Class;

Why choosing named access for New_BorderLayout and anonymous access for
AddLayoutComponent or GetLayoutComponent for the type of parameters
P1_xxx and the return type?
Why not all named or all anonymous ?

Thanks, Pascal.

Re: Equivalence between named access and anonymous access.

<udct43$3200c$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10016&group=comp.lang.ada#10016

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Equivalence between named access and anonymous access.
Date: Thu, 7 Sep 2023 18:18:11 +0200
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <udct43$3200c$1@dont-email.me>
References: <uda2ql$2hle9$1@dont-email.me> <uda7c1$2ids2$1@dont-email.me>
<udcsdo$31uib$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 7 Sep 2023 16:18:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b97c7f9cd77bb8f7702f299c14add81e";
logging-data="3211276"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nQxbQ2rnYlJ0sn53QIKk9gUOIAucenU0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.15.0
Cancel-Lock: sha1:IuxOeepBPLKBuFL/RXcHG25qGTM=
Content-Language: en-US
In-Reply-To: <udcsdo$31uib$1@dont-email.me>
 by: Jeffrey R.Carter - Thu, 7 Sep 2023 16:18 UTC

On 2023-09-07 18:06, Blady wrote:
>
> Why choosing named access for New_BorderLayout and anonymous access for
> AddLayoutComponent or GetLayoutComponent for the type of parameters P1_xxx and
> the return type?

It's very poor design to have access types in the visible part of a non-private
pkg spec.

--
Jeff Carter
"This language [Ada] has a remarkable power of expressiveness,
something vital to the rapid development of complicated software,
and its 'strong typing' makes it easy to debug and modify."
Scott and Bagheri
160

Re: Equivalence between named access and anonymous access.

<udd76k$33gb1$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10017&group=comp.lang.ada#10017

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: p.p11@orange.fr (Blady)
Newsgroups: comp.lang.ada
Subject: Re: Equivalence between named access and anonymous access.
Date: Thu, 7 Sep 2023 21:10:12 +0200
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <udd76k$33gb1$1@dont-email.me>
References: <uda2ql$2hle9$1@dont-email.me> <uda7c1$2ids2$1@dont-email.me>
<udcsdo$31uib$1@dont-email.me> <udct43$3200c$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 7 Sep 2023 19:10:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="68eaaf7d227959c42758bdcbaf13b1a8";
logging-data="3260769"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/M/HqJr2ITab84ZKedkFyL"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.13.0
Cancel-Lock: sha1:+iW3X63kWO5ojZEbx0dBsCGAQqk=
Content-Language: fr, en-US
In-Reply-To: <udct43$3200c$1@dont-email.me>
 by: Blady - Thu, 7 Sep 2023 19:10 UTC

Le 07/09/2023 à 18:18, Jeffrey R.Carter a écrit :
> On 2023-09-07 18:06, Blady wrote:
>>
>> Why choosing named access for New_BorderLayout and anonymous access
>> for AddLayoutComponent or GetLayoutComponent for the type of
>> parameters P1_xxx and the return type?
>
> It's very poor design to have access types in the visible part of a
> non-private pkg spec.
>

Hello Jeff,

I got you point :-)

But, in this specific case, I was wondering why not writing all with
named access or all with anonymous access?

Pascal.

Re: Equivalence between named access and anonymous access.

<uddbg7$3458e$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10018&group=comp.lang.ada#10018

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Equivalence between named access and anonymous access.
Date: Thu, 7 Sep 2023 22:23:37 +0200
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <uddbg7$3458e$1@dont-email.me>
References: <uda2ql$2hle9$1@dont-email.me> <uda7c1$2ids2$1@dont-email.me>
<udcsdo$31uib$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 7 Sep 2023 20:23:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3e4fde5204bf1fe9ab276fdba6340f70";
logging-data="3282190"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZLNPPgGHmTrP80Ga0M10aaPyU3EQlv28="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.0
Cancel-Lock: sha1:9nQOyz9FTIognXE0GCn9EqfKdrY=
In-Reply-To: <udcsdo$31uib$1@dont-email.me>
Content-Language: en-US
 by: Dmitry A. Kazakov - Thu, 7 Sep 2023 20:23 UTC

On 2023-09-07 18:06, Blady wrote:

> Well, I was questioning myself about the choice between named access and
> anonymous access in the old Ada port of Java library, for instance:
>
>    type Typ;
>    type Ref is access all Typ'Class;
>    type Typ(LayoutManager2_I : Java.Awt.LayoutManager2.Ref;
>             Serializable_I : Java.Io.Serializable.Ref)
>     is new Java.Lang.Object.Typ
>       with null record;
>    ------------------------------
>    -- Constructor Declarations --
>    ------------------------------
>    function New_BorderLayout (This : Ref := null)
>                               return Ref;

Contravariance is unsafe. I gather that Typ is tagged. If you ever
derive from it, it will "inherit" the broken construction function,
because the function is class-wide. The safe choice here is anonymous
access. The compiler will require to override the construction function.
That is for the return value. The case for the argument depends. Again
anonymous access type is more handy but if you going to copy/store
references, then named types are better.

> Why not all named or all anonymous ?

My rough rule is like this:

Do not expose access types if you can.

If you successfully hidden them either completely or by declaring them
private, then named they go.

If you exposed access types, then anonymous access is usually a better
choice because it is easier to use, especially when access is merely to
work around language limitations on argument/result passing
(unconstrained object, access rules nightmare) AKA closures. Then it
much is safer in a hierarchy of types and it is more use-clause friendly.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor