comp.lang.ada
 help / color / mirror / Atom feed
* "accessibility check failed" on Node
@ 2013-06-26 23:01 Thomas Schmidt
  2013-06-26 23:45 ` Shark8
                   ` (5 more replies)
  0 siblings, 6 replies; 19+ messages in thread
From: Thomas Schmidt @ 2013-06-26 23:01 UTC (permalink / raw)


Hi,

I'm new to Ada. I'm trying to write some kind of neural net software. 
Therefore I've written a small library to implement the neural graph. 
All nodes are collected in a Hashed_Set. Neurons are specialized Nodes 
of the graph. To lookup a given Neuron/Node I need the following 
subprogram "findNode".

Now what I don't understand: Why does "findNode1" work well while 
"findNode2" raises PROGRAM_ERROR at the line indicated below?


Given the following declarations:

   -- Node of a directed graph
   type Node is new NodeBase with private;	-- NodeBase is tagged.
   type Node_Class_Access is access all Node'Class;

and the DirectedGraph is a tagged record with one of its elements 
(named "nodes") being a NodeSet defined as a Set of my NodeSets package

  package NodeSets is new Ada.Containers.Hashed_Sets (
     Element_Type        => Node_Class_Access,
     Hash                => Nodes.hash,
     Equivalent_Elements => Nodes.equiv);

   --------------
   -- findNode1 --
   --------------

   function findNode1
     (graph : DirectedGraph;
      aNode : access Node'Class)
      return  Node_Class_Access is

      position : constant NodeSets.Cursor :=
        graph.nodes.Find (Node (aNode.all)'Access);	-- <<< Works well

   begin
      if position /= NodeSets.No_Element then
         return Element (position);
      else
         raise NoElement;
      end if;
   end findNode1;

   --------------
   -- findNode2 --
   --------------

   function findNode2
     (graph : DirectedGraph;
      aNode : access Node'Class)
      return  Node_Class_Access is

      position : constant NodeSets.Cursor :=
        graph.nodes.Find (aNode.all'Access);	-- <<< Raises 
PROGRAM_ERROR with "accessibility check failed"

   begin
      if position /= NodeSets.No_Element then
         return Element (position);
      else
         raise NoElement;
      end if;
   end findNode2;

"findNote" will be called with a Neuron as its second argument.


Many thanks for your explanations

Thomas

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

end of thread, other threads:[~2013-06-28  0:52 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-26 23:01 "accessibility check failed" on Node Thomas Schmidt
2013-06-26 23:45 ` Shark8
2013-06-26 23:58 ` Jeffrey Carter
2013-06-27  7:36 ` Georg Bauhaus
2013-06-27  7:49 ` Dmitry A. Kazakov
2013-06-27  8:24 ` Simon Wright
2013-06-27 11:19   ` Thomas Schmidt
2013-06-27 12:49     ` Frédéric Praca
2013-06-27 14:36     ` Eryndlia Mavourneen
2013-06-27 17:31       ` Jeffrey Carter
2013-06-27 17:45         ` Simon Wright
2013-06-27 23:26           ` Randy Brukardt
2013-06-28  0:52             ` Jeffrey Carter
2013-06-27 18:33         ` Eryndlia Mavourneen
2013-06-27 20:31           ` Jeffrey Carter
2013-06-27 23:29             ` Randy Brukardt
2013-06-27 14:51     ` Shark8
2013-06-27 17:29     ` Jeffrey Carter
2013-06-27 10:46 ` Stephen Leake

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