From: Thomas Schmidt <TC.Schmidt@gmx.net>
Subject: "accessibility check failed" on Node
Date: Thu, 27 Jun 2013 01:01:19 +0200
Date: 2013-06-27T01:01:19+02:00 [thread overview]
Message-ID: <kqfrrv$lsb$1@news2.open-news-network.org> (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
next reply other threads:[~2013-06-26 23:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-26 23:01 Thomas Schmidt [this message]
2013-06-26 23:45 ` "accessibility check failed" on Node 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox