comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: A novel design of linked lists
Date: Thu, 21 Sep 2006 10:22:03 +0200
Date: 2006-09-21T10:22:03+02:00	[thread overview]
Message-ID: <9fxr2culkhv7.v6vz7mts1q04.dlg@40tude.net> (raw)
In-Reply-To: 1158772432.768630.183720@e3g2000cwe.googlegroups.com

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



  reply	other threads:[~2006-09-21  8:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-19 13:30 A novel design of linked lists (was: Address of an object) Dmitry A. Kazakov
2006-09-19 20:09 ` Adam Beneschan
2006-09-20  8:35   ` A novel design of linked lists Dmitry A. Kazakov
2006-09-20 17:13     ` Adam Beneschan
2006-09-21  8:22       ` Dmitry A. Kazakov [this message]
2006-09-19 22:42 ` A novel design of linked lists (was: Address of an object) Leif Holmgren
2006-09-20  8:44   ` A novel design of linked lists Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox