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,T_SCC_BODY_TEXT_LINE, XPRIO autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "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 Message-ID: References: <9a5e9c8b-c263-4ac7-86f8-97a8ee1fdb99n@googlegroups.com> 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 Xref: reader02.eternal-september.org comp.lang.ada:63904 List-Id: "Dmitry A. Kazakov" 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.