@@ -51,10 +51,33 @@ export head
51
51
"""
52
52
children(x)
53
53
Returns 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`.
54
62
"""
55
63
function children end
56
64
export children
57
65
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
+
58
81
"""
59
82
operation(x)
60
83
@@ -69,20 +92,30 @@ export operation
69
92
70
93
Returns the arguments to the function call in a function call expression.
71
94
`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`.
72
102
"""
73
103
function arguments end
74
104
export arguments
75
105
76
106
"""
77
- unsorted_arguments (x::T)
107
+ sorted_arguments (x::T)
78
108
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.
83
116
"""
84
- unsorted_arguments (x) = arguments (x)
85
- export unsorted_arguments
117
+ sorted_arguments (x) = arguments (x)
118
+ export sorted_arguments
86
119
87
120
88
121
"""
0 commit comments