Skip to content

Commit 04cedfb

Browse files
committed
Merge branch 'pmderodat/can_reach' into 'master'
Lexical envs: clarify the documentation of Can_Reach See merge request eng/libadalang/langkit!829
2 parents 1fb4550 + cd3c05f commit 04cedfb

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

langkit/support/langkit_support-lexical_envs_impl.ads

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,21 @@ generic
6060
with function Combine (L, R : Node_Metadata) return Node_Metadata;
6161

6262
with function Can_Reach (Node, From : Node_Type) return Boolean is <>;
63-
-- Function that will allow filtering nodes depending on the origin node of
64-
-- the request. In practice, this is used to implement sequential semantics
65-
-- for lexical envs, as-in, node declared after another is not yet visible.
63+
-- Return whether ``Node`` can be reached from ``From``.
64+
--
65+
-- This function is used to filter the result of a lexical env lookup: for
66+
-- a lookup triggered on node ``From`` (formal ``From`` in
67+
-- ``Get``/``Get_First`` functions), nodes ``Node`` for which ``Can_Reach
68+
-- (Node, From)`` returns False are excluded from the result.
69+
--
70+
-- This is used to implement sequential semantics: in the following
71+
-- example, looking for ``D`` from the second line should return the
72+
-- definition in the first line (``E`` can reach ``D`` line 1), but not the
73+
-- one in the third line (``E`` cannot reach ``D`` line 3)::
74+
--
75+
-- def D = 1
76+
-- def E = D
77+
-- def D = 2
6678

6779
with function Is_Rebindable (Node : Node_Type) return Boolean is <>;
6880
-- Return whether a lexical environment whose node is Node can be rebound

0 commit comments

Comments
 (0)