comp.lang.ada
 help / color / mirror / Atom feed
* Using Grace.Lists.Unbounded in WindowsXP/GNAT3.15p
@ 2003-03-13 10:16 Frank
  2003-03-13 14:51 ` Stephen Leake
  2003-03-13 16:26 ` Matthew Heaney
  0 siblings, 2 replies; 4+ messages in thread
From: Frank @ 2003-03-13 10:16 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2379 bytes --]


Hi!

Using WindowsXP/GNAT3.15p/Grace.Lists "1.1".

See source code and execution-dump at the end.

1)
In this example I add a number of nodes to a list, and traverse them
successfully to
print their contence.

2)
I traverse the list until the second node.
Then I try to remove the second Node.
The library now throws me a CONSTRAINT_ERROR.


Where am I mistaking?


----

The big picture(but not fully coded in this example):
What I want to achieve is to be able to traverse a list, and based on
information in the
node, decide to remove it from the current position in the list and reinsert
it at the end.
This is done to postpone the calculation of the Node until all other Nodes
have been calculated.


Frank J�rgensen


------------------------------------------------
with Grace.Lists.Unbounded;
with Test_List_Pkg;
with Ada.Text_IO;

procedure Test_List is

  Allowed_Nodes : Test_List_Pkg.Test_Nodes.List :=
Test_List_Pkg.Test_Nodes.Empty;
  Tmp_Trav : Test_List_Pkg.Test_Nodes.Iterator;
  Tmp_Data : Integer;
begin

  Test_List_Pkg.Test_Nodes.Insert (Allowed_Nodes, 1,
Test_List_Pkg.Test_Nodes.Tail);
  Test_List_Pkg.Test_Nodes.Insert (Allowed_Nodes, 2,
Test_List_Pkg.Test_Nodes.Tail);
  Test_List_Pkg.Test_Nodes.Insert (Allowed_Nodes, 3,
Test_List_Pkg.Test_Nodes.Tail);
  Test_List_Pkg.Test_Nodes.Insert (Allowed_Nodes, 4,
Test_List_Pkg.Test_Nodes.Tail);

  Tmp_Trav := Test_List_Pkg.Test_Nodes.Head(Allowed_Nodes);

  while Test_List_Pkg.Test_Nodes.Has_Item(Tmp_Trav)  loop
    Tmp_Data := Test_List_Pkg.Test_Nodes.Item(Tmp_Trav);


    Ada.Text_IO.Put_Line("---" & Tmp_Data'Img);
    Tmp_Trav := Test_List_Pkg.Test_Nodes.Next(Tmp_Trav,
Test_List_Pkg.Test_Nodes.Tail);
  end loop;

  Tmp_Trav := Test_List_Pkg.Test_Nodes.Head(Allowed_Nodes);
  Tmp_Trav := Test_List_Pkg.Test_Nodes.Next(Tmp_Trav,
Test_List_Pkg.Test_Nodes.Tail);

  Test_List_Pkg.Test_Nodes.Remove (Tmp_Trav, Test_List_Pkg.Test_Nodes.Tail);

end Test_List;

------------------------------------------------
with Grace.Lists.Unbounded;

package Test_List_Pkg is
  package Test_Nodes is new Grace.Lists.Unbounded (Integer);
end Test_List_Pkg;

------------------------------------------------
--- 1
--- 2
--- 3
--- 4
ERROR: After finalization of Empty object,  6 items have been allocated
and  5 items have been freed.

raised CONSTRAINT_ERROR : grace-lists-unbounded.adb:70 access check failed









^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using Grace.Lists.Unbounded in WindowsXP/GNAT3.15p
  2003-03-13 10:16 Using Grace.Lists.Unbounded in WindowsXP/GNAT3.15p Frank
@ 2003-03-13 14:51 ` Stephen Leake
  2003-03-13 15:56   ` Frank
  2003-03-13 16:26 ` Matthew Heaney
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Leake @ 2003-03-13 14:51 UTC (permalink / raw)


"Frank" <franjoe@frisurf.no> writes:

> Hi!
> 
> Using WindowsXP/GNAT3.15p/Grace.Lists "1.1".
> 
> See source code and execution-dump at the end.
> 
> 1)
> In this example I add a number of nodes to a list, and traverse them
> successfully to
> print their contence.
> 
> 2)
> I traverse the list until the second node.
> Then I try to remove the second Node.
> The library now throws me a CONSTRAINT_ERROR.
> 
> 
> Where am I mistaking?

I'll look at this in detail later. But I suspect the problem is a
design flaw in the current example implementation of
Grace.Lists.Unbounded. Try declaring "Allowed_Nodes" at library level,
rather than in a procedure; I think the "access check failed" is not a
null access but a "nesting level" access failure.

When I implemented a draft version of Grace.Lists.Unbounded, I had to
add an extra layer of indirection to avoid this problem. The current
example implementation does not do that.

> The big picture(but not fully coded in this example):
> What I want to achieve is to be able to traverse a list, and based on
> information in the
> node, decide to remove it from the current position in the list and reinsert
> it at the end.
> This is done to postpone the calculation of the Node until all other Nodes
> have been calculated.

It is reasonable to expect Grace.Lists to handle this.

Until a better implementation of Grace is available (care to
contribute one? :), you might try SAL or Charles or Booch or ...

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using Grace.Lists.Unbounded in WindowsXP/GNAT3.15p
  2003-03-13 14:51 ` Stephen Leake
@ 2003-03-13 15:56   ` Frank
  0 siblings, 0 replies; 4+ messages in thread
From: Frank @ 2003-03-13 15:56 UTC (permalink / raw)



Thank you for answer.

Frank





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using Grace.Lists.Unbounded in WindowsXP/GNAT3.15p
  2003-03-13 10:16 Using Grace.Lists.Unbounded in WindowsXP/GNAT3.15p Frank
  2003-03-13 14:51 ` Stephen Leake
@ 2003-03-13 16:26 ` Matthew Heaney
  1 sibling, 0 replies; 4+ messages in thread
From: Matthew Heaney @ 2003-03-13 16:26 UTC (permalink / raw)


"Frank" <franjoe@frisurf.no> wrote in message news:<3e705a78$1@news.wineasy.se>...
> 
> The big picture(but not fully coded in this example):
> What I want to achieve is to be able to traverse a list, and based on
> information in the
> node, decide to remove it from the current position in the list and reinsert
> it at the end.
> This is done to postpone the calculation of the Node until all other Nodes
> have been calculated.

You said you're using GRACE, but here's how you'd do it in Charles:

procedure Op (List : in List_Subtype) is
   I : Iterator_Type := First (List);
   J : constant Iterator_Type := Back (List);
begin
   while I /= J loop
      declare
         E : Element_Subtype renames To_Access (I).all;   
      begin
         if Predicate (E) then
            Splice (List, Before => J, Iterator => I);
            return;
         end if;
      end;

      I := Succ (I);
   end loop;
end Op;

http://home.earthlink.net/~matthewjheaney/charles/



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-03-13 16:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-13 10:16 Using Grace.Lists.Unbounded in WindowsXP/GNAT3.15p Frank
2003-03-13 14:51 ` Stephen Leake
2003-03-13 15:56   ` Frank
2003-03-13 16:26 ` Matthew Heaney

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