Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Refreshed by a brief blackout, I got to my feet and went next door. -- Martin Amis, _Money_


devel / comp.lang.ada / Re: Problems using Generic_Dispatching_Constructor

SubjectAuthor
* Problems using Generic_Dispatching_ConstructorMark Lorenzen
`* Re: Problems using Generic_Dispatching_ConstructorDmitry A. Kazakov
 `- Re: Problems using Generic_Dispatching_ConstructorRandy Brukardt

1
Problems using Generic_Dispatching_Constructor

<9a5e9c8b-c263-4ac7-86f8-97a8ee1fdb99n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:622a:110f:b0:2f3:c9f1:ada4 with SMTP id e15-20020a05622a110f00b002f3c9f1ada4mr51761293qty.197.1654083363314;
Wed, 01 Jun 2022 04:36:03 -0700 (PDT)
X-Received: by 2002:a81:2185:0:b0:2f1:de50:5ecb with SMTP id
h127-20020a812185000000b002f1de505ecbmr71297368ywh.40.1654083363157; Wed, 01
Jun 2022 04:36:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.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, 1 Jun 2022 04:36:02 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=93.165.155.46; posting-account=Srm5lQoAAAAEMX9rv2ilEKR6FDPapmSq
NNTP-Posting-Host: 93.165.155.46
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9a5e9c8b-c263-4ac7-86f8-97a8ee1fdb99n@googlegroups.com>
Subject: Problems using Generic_Dispatching_Constructor
From: mark.lor...@gmail.com (Mark Lorenzen)
Injection-Date: Wed, 01 Jun 2022 11:36:03 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2638
 by: Mark Lorenzen - Wed, 1 Jun 2022 11:36 UTC

The generic function Ada.Tags.Generic_Dispatching_Constructor is defined as:

generic
type T (<>) is abstract tagged limited private;
type Parameters (<>) is limited private;
with function Constructor (Params : not null access Parameters) return T is abstract;

function Ada.Tags.Generic_Dispatching_Constructor (The_Tag : Tag; Params : not null access Parameters) return T'Class;

This gives us some problems when calling an instance of Ada.Tags.Generic_Dispatching_Constructor when the Params parameter is an in-mode parameter of a function e.g.:

function Make (From_Params : in P) return T'Class
is
function Make_T_Class is new Ada.Tags.Ada.Tags.Generic_Dispatching_Constructor (T => T, Parameters => P, Constructor => ...);
begin
...
return Make_T_Class (Some_Tag, P'Access);
end Make;

This results in a compile-time error:
error: access-to-variable designates constant

Why is function Ada.Tags.Generic_Dispatching_Constructor defined as:
function Ada.Tags.Generic_Dispatching_Constructor (The_Tag : Tag; Params : not null access Parameters) return T'Class;

and not as e.g (note the access-to-constant type):
function Ada.Tags.Generic_Dispatching_Constructor (The_Tag : Tag; Params : not null access constant Parameters) return T'Class;

I guess we could declare function Make as (note the in-out mode):
function Make (From_Params : in out P) return T'Class
But this is horrible as functions should never ever have in-out or out-mode parameters (or side effects in general).

Why are access types used at all?

Is there another workaround?

Regards,
Mark L

Re: Problems using Generic_Dispatching_Constructor

<t77mrv$1e20$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!siG8trSPtxwtkBCOZpBn8A.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Problems using Generic_Dispatching_Constructor
Date: Wed, 1 Jun 2022 14:42:40 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t77mrv$1e20$1@gioia.aioe.org>
References: <9a5e9c8b-c263-4ac7-86f8-97a8ee1fdb99n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="47168"; posting-host="siG8trSPtxwtkBCOZpBn8A.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Wed, 1 Jun 2022 12:42 UTC

On 2022-06-01 13:36, Mark Lorenzen wrote:

> Why are access types used at all?

Parameters are kind of factory object, you want to have the factory mutable.

> Is there another workaround?

In my practice I never had a case when I could obtain the tag needed for
generic dispatching constructor. All my designs ended up with a mapping

key -> constructing function

with an explicit registering the type in the mapping.

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

Re: Problems using Generic_Dispatching_Constructor

<t78lfu$rve$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ran...@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: Problems using Generic_Dispatching_Constructor
Date: Wed, 1 Jun 2022 16:25:16 -0500
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <t78lfu$rve$1@dont-email.me>
References: <9a5e9c8b-c263-4ac7-86f8-97a8ee1fdb99n@googlegroups.com> <t77mrv$1e20$1@gioia.aioe.org>
Injection-Date: Wed, 1 Jun 2022 21:25:18 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e091d6e4097c0c85b8fa2a28aaea7cae";
logging-data="28654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18woE4jAfneyuAs8RlmFi9RxnoXG0M/GE8="
Cancel-Lock: sha1:JzjoWPnJ6bS/S9GTfA/WmxjXTWU=
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
X-RFC2646: Format=Flowed; Response
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-Priority: 3
X-MSMail-Priority: Normal
 by: Randy Brukardt - Wed, 1 Jun 2022 21:25 UTC

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:t77mrv$1e20$1@gioia.aioe.org...
> On 2022-06-01 13:36, Mark Lorenzen wrote:
>
>> Why are access types used at all?

We needed this usable to implement dispatching stream attributes (the
generic dispatching constructor was intended to be a user-definable
generalization of the mechanism of the class-wide stream attribute). The
stream attributes probably used access types because "in out" parameters
were not allowed for functions when they were invented. (So mistakes piled
on mistakes. :-)

> Parameters are kind of factory object, you want to have the factory
> mutable.

Right. For instance, consider a factory where each object gets a unique ids
while being constructed. You would want to update the Next_Id component at
the end of each construction.

>> Is there another workaround?
>
> In my practice I never had a case when I could obtain the tag needed for
> generic dispatching constructor. All my designs ended up with a mapping
>
> key -> constructing function
>
> with an explicit registering the type in the mapping.

Right. Generally, one uses a mapping of some sort of key or menu choice or
whatever to tags. If you aren't adverse to a giant case statement, then you
might as well call the constructor directly. (And if you are willing to use
access-to-functions, you don't need OOP at all.) So this "factory" is mostly
a bone for OOP purists.

The one exception is the case where you have an external tag as the key,
since you can get the tag from that directly. But even that is really a
mapping (one built by the implementation).

Randy.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor