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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,fd189a20f95495f3 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!r9g2000yql.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Task components, the rationale Date: Thu, 14 Jul 2011 11:15:53 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <4e1eae6c$0$6570$9b4e6d93@newsspool3.arcor-online.net> NNTP-Posting-Host: 83.3.40.82 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1310667353 2203 127.0.0.1 (14 Jul 2011 18:15:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 14 Jul 2011 18:15:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r9g2000yql.googlegroups.com; posting-host=83.3.40.82; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20203 Date: 2011-07-14T11:15:53-07:00 List-Id: On Jul 14, 10:52=A0am, Georg Bauhaus wrote: > > You have to just, you know, simply, introduce constructors to the > > language. This is my pet feature for Ada 2020. :-) > > Out of curiosity, would this be enough? It would not be sufficient, but it would be necessary. The point is, in order to solve these kind of puzzles you have to recognize initialization as a special operation (ie. stop pretending that it can be a regular primitive operation of a type) and use that notion to impose special rules. In the case of access discriminants the circular relationship is possible to discover statically. After all, the whole T'Access "expression" is special, and allowed only in this particular case. Once you statically know you have a problem, you can work from there - but no matter what kind of restrictions or provisions you impose in the constructor, you have to recognize that it is a special operation, not a regular primitive one. If you ask me from the top of my head how *exactly* this can be solved, I will not attempt to give a full solution (hey, the committee has a full decade for it ;-) ), but one of the possible ideas might involve adding a lifetime information to the access discriminant, just as it is done for tracking scopes of types and objects with anonymous access parameters today. That is, raise Program_Error when you discover that within the constructor of T its access discriminant (pointer to outer) is dereferenced while the outer was not yet initialized. Most cases (like the two examples we have shown) can be fully analyzed statically for this. > Assuming, naively, not knowing C++, that constructors of C++ > could lead the way, They will not lead the way in solving the problem of dangling pointers, because this is not the problem that C++ was designed to solve in general. But recognizing that the constructor is a special place is an important contribution. -- Maciej Sobczak * http://www.msobczak.com * http://www.inspirel.com