From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.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 Lorenzen Injection-Date: Wed, 01 Jun 2022 11:36:03 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 2638 Xref: reader02.eternal-september.org comp.lang.ada:63898 List-Id: 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