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,95e71dd4ab1859a5 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!news.glorb.com!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.hanau.net!noris.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: A novel design of linked lists Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.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: <1erhzx6bo87fc.lzgqxpirn16r.dlg@40tude.net> <1158696584.069704.6780@m7g2000cwm.googlegroups.com> <1158772432.768630.183720@e3g2000cwe.googlegroups.com> Date: Thu, 21 Sep 2006 10:22:03 +0200 Message-ID: <9fxr2culkhv7.v6vz7mts1q04.dlg@40tude.net> NNTP-Posting-Date: 21 Sep 2006 10:22:03 CEST NNTP-Posting-Host: 41f98426.newsspool1.arcor-online.net X-Trace: DXC=n7T\oeh`[6l]BlmkiiU@Biic==]BZ:afn4Fo<]lROoRagUcjd<3m<;bg>ib83h:^Oh[6LHn;2LCVn7enW;^6ZC`dF0oL On 20 Sep 2006 10:13:52 -0700, Adam Beneschan wrote: > Dmitry A. Kazakov wrote: > >> Hmm, if you consider a need in downcasting and explicit type conversions of >> elements of a double-linked lists as OK, then we are on different pages. > > Apparently we are. I don't see why it wouldn't be OK to declare > Item_Ptr as some sort of private type, and have users of the package > write Deref(P) instead of P.all when they want to get the pointed-to > value---or, if you want to be able to put it on the left side of an > assignment, include a function that returns a general-access to your > list type so that they could say something like The_Item(P).all := > something. You seem to think this is awful, and I don't see anything > wrong with it, so yes, we are on different pages. Yes I do, because I there is no obvious reason why the referential nature of Item_Ptr need to be hidden. To be honest, I don't think that .all is good. IMO, pointers should be fully transparent in Ada. But in the case at hand we cannot get rid of .all. You have replaced one pointer type with another. This does not make much sense to me. Then there is a technical problem, when Item_Ptr is private, you will need a mediator type between Item_Ptr and the item factory and shredder + a lot of acrobatics. In my design they are just new and an instance of Unchecked_Deallocation. >>> Put simply, you're trying to trick your Ada compiler into allowing >>> programmers to use Ada syntax to write code in some other language than >>> Ada, and someone who looks at the Ada code and assumes it's Ada is >>> likely to be pretty darn confused. >> >> Hmm, this definitely applies to the dopes of String objects. Is String Ada? > > I'm not sure what you mean here. When you declare an access to a > string, in Ada you can use that access to get at the string value---and > that includes not just the contents of each character, but the 'First > and 'Last attributes of the string, which are an important property of > the value. I'm sure that's what you mean by "dope", but to me "dope" > is an implementation detail, not an Ada concept. But if I define a > record type that doesn't have "next" or "previous" fields, then I don't > expect "next" and "previous" to be part of the value that is accessed > when I declare an access to that record type---or when you declare it > in your generic. This is just how I think. There's apparently a > philosophical chasm here, though. Yes, because in my philosophy there is no any difference between X"First and Next (X). Both are just [primitive] operations on some ADT. Neither assumes that the result must be additionally accessible as a field, either publicly or privately. (BTW, even a field is, in fact, a pair of primitive operations getter/setter, alas, not in Ada.) To me the way 'First get computed is an implementation detail, same for Next. To me it is quite in Ada-way, when the compiler allocates an invisible dope for String and exposes this implementation detail through well-formed public interface of array attributes. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de