comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Pop function
Date: Thu, 15 Dec 2011 18:34:53 +0000
Date: 2011-12-15T18:34:53+00:00	[thread overview]
Message-ID: <m2iplh8z02.fsf@pushface.org> (raw)
In-Reply-To: 0357a0a8-9e3e-4011-bb40-0d82700d70b2@o7g2000yqk.googlegroups.com

Adam Beneschan <adam@irvine.com> writes:

> On Dec 15, 4:43 am, Simon Wright <si...@pushface.org> wrote:

>> I don't see why Pop takes T_List_Ptr as an argument. I would have
>> written
>>
>>     procedure Pop (Sender : in out T_List;
>>                    T_Item : out Integer) is
>>
>> and then it would be primitive (assuming T_List is tagged).

> You could quibble about whether T_List is an appropriate name to
> represent a list element.  Fine.  I would too.  But I think our first
> objective should get our OP to help write code that works, which
> involves making sure he (I assume) understands the Ada language issues
> involved, and not adding to any confusion he might have.  We can
> quibble about the names, readability issues, encapsulation issues,
> etc., later.

I see what you mean; you've realised that OP is probably confused,
whereas I just got confused myself.

I agree about writing code that works, but that does sometimes involve
working out how best to state the problem. I don't think that it's
quibbling to point to unclear thinking; if the design is wrong that's
not an Ada language issue, and using inappropriate names is a red flag
for design problems.

Here, for example, if I write

      L : aliased T_List;
      ...
   begin
      ...
      J := Pop (L'Access);

I'm going to get a crash at runtime because I'm trying to deallcate
memory that was never allocated.

I have in the past implemented lists where the 'head' element was just
another member which -- by convention -- wasn't part of the list. That
sort of thing needs to be done by consenting adults in private, though.





  reply	other threads:[~2011-12-15 18:35 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-15  0:06 Pop function Rego, P.
2011-12-15  0:29 ` Martin Dowie
2011-12-15  1:23   ` Rego, P.
2011-12-15  2:08   ` Adam Beneschan
2011-12-15 22:59     ` Martin Dowie
2011-12-16 10:27       ` georg bauhaus
2011-12-15  0:34 ` Jeffrey Carter
2011-12-15  1:35   ` Rego, P.
2011-12-15  2:55     ` Alex Mentis
2011-12-15  3:00       ` Alex Mentis
2011-12-15  3:00     ` Jeffrey Carter
2011-12-15  3:41       ` Rego, P.
2011-12-15  8:38   ` Dmitry A. Kazakov
2011-12-15 19:57     ` Jeffrey Carter
2011-12-15 20:15       ` Dmitry A. Kazakov
2011-12-15 21:02         ` Simon Wright
2011-12-15 21:25           ` Jeffrey Carter
2011-12-16  8:23           ` Dmitry A. Kazakov
2011-12-16  0:31       ` Randy Brukardt
2011-12-15  2:06 ` Adam Beneschan
2011-12-15  3:27   ` Rego, P.
2011-12-15 12:43     ` Simon Wright
2011-12-15 15:54       ` Adam Beneschan
2011-12-15 18:34         ` Simon Wright [this message]
2011-12-15 19:14           ` Dmitry A. Kazakov
2011-12-15 16:14     ` Adam Beneschan
2011-12-28 13:04       ` Rego, P.
replies disabled

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