From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!mx05.eternal-september.org!feeder.eternal-september.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news.babsi.de!open-news-network.org!news2.open-news-network.org!.POSTED!not-for-mail From: Thomas Schmidt Newsgroups: comp.lang.ada Subject: "accessibility check failed" on Node Date: Thu, 27 Jun 2013 01:01:19 +0200 Organization: news.babsi.de for open-news-network.org Message-ID: NNTP-Posting-Host: ltea-047-067-147-043.pools.arcor-ip.net Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news2.open-news-network.org 1372287680 22411 47.67.147.43 (26 Jun 2013 23:01:20 GMT) X-Complaints-To: abuse@open-news-network.org NNTP-Posting-Date: Wed, 26 Jun 2013 23:01:20 +0000 (UTC) User-Agent: Unison/2.1.10 Xref: news.eternal-september.org comp.lang.ada:15943 Date: 2013-06-27T01:01:19+02:00 List-Id: 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