comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@acm.nospam.org>
Subject: Re: access assignation. Aliasing problems?
Date: Fri, 01 Feb 2008 18:24:28 GMT
Date: 2008-02-01T18:24:28+00:00	[thread overview]
Message-ID: <wtJoj.11347$yE1.9258@attbi_s21> (raw)
In-Reply-To: <6766a791-abf3-4571-b5f7-98751a948f13@j78g2000hsd.googlegroups.com>

Javi wrote:
>          L.Last := new ListNode'(Item => It, next => null);
>          L.First := L.Last; -- this fails, L.First and L.Last are both
> the same type access ListNode

I suspect you're saying that type List has components such as

type List is record
    First : access Listnode;
    Last  : access Listnode;
    ...
end record;

The solution is simple: Don't use anonymous types. Use a named type instead:

type Node_Ptr is access Listnode; -- Using '_' is The Ada Way.

type List is record
    First : Node_Ptr;
    Last  : Node_Ptr;
    ...
end record;

Anonymous types are a horrible thing and should be avoided whenever possible.

-- 
Jeff Carter
"Sir Robin the-not-quite-so-brave-as-Sir-Lancelot,
who had nearly fought the Dragon of Angnor,
who nearly stood up to the vicious Chicken of Bristol,
and who had personally wet himself at the
Battle of Badon Hill."
Monty Python & the Holy Grail
68



  parent reply	other threads:[~2008-02-01 18:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-01 10:01 access assignation. Aliasing problems? Javi
2008-02-01 14:02 ` Robert A Duff
2008-02-01 18:24 ` Jeffrey R. Carter [this message]
2008-02-02 10:37   ` Stephen Leake
2008-02-02 21:02     ` Javi
replies disabled

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