From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2e2db8edf2656165 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Constructing an object Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1lw8oz33ao529.12ep5ay7rg4oc$.dlg@40tude.net> <5-GdnRjCgYZOfKneRVn-qw@megapath.net> Date: Sat, 24 Sep 2005 11:47:18 +0200 Message-ID: <3dachnu33lly.fpr0wvf6nj05$.dlg@40tude.net> NNTP-Posting-Date: 24 Sep 2005 11:47:03 MEST NNTP-Posting-Host: 2dc2e6d0.newsread2.arcor-online.net X-Trace: DXC=k^9]mc5oV:g18V74W6`bolQ5U85hF6f;djW\KbG]kaMhGSi?jHD8GO`T3QCn83K6Jb[6LHn;2LCVnI^><>f3dFYjE\jSVi`h\_k X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:5088 Date: 2005-09-24T11:47:03+02:00 List-Id: On Sat, 24 Sep 2005 00:23:01 -0500, Randy Brukardt wrote: > In Ada 200Y, access discriminants are allowed on nonlimited > types, but they then cannot have defaults (such discriminants cannot change > after object creation, and we needed to disallow changing them via > assignment). How? The type should be then abstract or unconstrained and the user should have rather its subtype with the discriminant limited to the value. > You also failed to mention that the object factory can be implemented > (probably *ought* to be implemented) with the Ada 200Y > Generic_Dispatching_Constructor. That takes a tag value and a dispatching > function and creates an appropriate object for the tag, initialized by the > dispatching function. That is a good news, though it still looks like hack. Generics is used to pass the parameters, instead of providing some native mechanism for determining the tag, discriminants, bounds and other constraints. One possibility could be to have for each type a predefined null-record type having the same discriminants (tag and bounds are mapped to discriminants). Then the object of this type could be passed to the allocator. IMO there should be proper constructors for all types. Constructing functions are too error-prone. Further, Ada needs extensible primitive and class-wide operations, that could finally solve the construction / assignment problem. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de