@@ -51,10 +51,33 @@ export head
5151"""
5252 children(x)
5353Returns the children (aka tail) of the S-expression.
54+
55+
56+ Depending on the type and internal representation of `x`,
57+ `children(x)` may return an unsorted collection nondeterministically,
58+ This is to make sure to retrieve the children of an AST node when the order of children does not matter,
59+ but the speed of the operation does.
60+ To ensure to retrieve children in a sorted manner, you can use
61+ and implement the function `sorted_children`.
5462"""
5563function children end
5664export children
5765
66+ """
67+ sorted_children(x::T)
68+
69+ Returns the children of an AST node, in a **sorted fashion**.
70+ `isexpr(x)` must be true as a precondition. Analogous to `children`,
71+ but ensures that the operation is deterministic and always returns
72+ the children in the order they are stored.
73+
74+ By default, this redirects to `children`, therefore implementing
75+ it is optional.
76+ """
77+ sorted_children (x) = children (x)
78+ export sorted_children
79+
80+
5881"""
5982 operation(x)
6083
@@ -69,20 +92,30 @@ export operation
6992
7093Returns the arguments to the function call in a function call expression.
7194`iscall(x)` must be true as a precondition.
95+
96+ Depending on the type and internal representation of `x`,
97+ `arguments(x)` may return an unsorted collection nondeterministically,
98+ This is to make sure to retrieve the arguments of an expression when the order of arguments does not matter
99+ but the speed of the operation does.
100+ To ensure to retrieve arguments in a sorted manner, you can use
101+ and implement the function `sorted_arguments`.
72102"""
73103function arguments end
74104export arguments
75105
76106"""
77- unsorted_arguments (x::T)
107+ sorted_arguments (x::T)
78108
79- If x is a expression satisfying `iscall(x)` and your expression type `T` provides
80- and optimized implementation for storing the arguments, this function can
81- be used to retrieve the arguments when the order of arguments does not matter
82- but the speed of the operation does.
109+ Returns the arguments to the function call in a function call expression, in a **sorted fashion**.
110+ `iscall(x)` must be true as a precondition. Analogous to `arguments`,
111+ but ensures that the operation is deterministic and always returns
112+ the arguments in the order they are stored.
113+
114+ By default, this redirects to `arguments`, therefore implementing
115+ it is optional.
83116"""
84- unsorted_arguments (x) = arguments (x)
85- export unsorted_arguments
117+ sorted_arguments (x) = arguments (x)
118+ export sorted_arguments
86119
87120
88121"""
0 commit comments