Skip to content

Commit 5ca6f6a

Browse files
authored
Improve JEP-3 content and formatting (#143)
* Fix typos in JEP-3 * Improve JEP-3 formatting * Refactor presentation of the JEP-3 nested function example
1 parent a53c6ed commit 5ca6f6a

File tree

1 file changed

+40
-55
lines changed

1 file changed

+40
-55
lines changed

jep-003-functions.md

Lines changed: 40 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -196,79 +196,64 @@ Below is a worked example. Given:
196196

197197
Evaluating `abs(foo)` works as follows:
198198

199-
200199
1. Evaluate the input argument against the current data:
200+
```
201+
search(foo, {"foo": -1, "bar": 2"}) -> -1
202+
```
201203

202-
```
203-
search(foo, {"foo": -11, "bar": 2"}) -> -1
204-
```
205-
206-
207-
2. Validate the type of the resolved argument. In this case
208-
`-1` is of type `number` so it passes the type check.
209-
204+
2. Validate the type of the resolved argument.
205+
In this case `-1` is of type `number` so it passes the type check.
210206

211207
3. Call the function with the resolved argument:
208+
```
209+
abs(-1) -> 1
210+
```
212211

213-
```
214-
abs(-1) -> 1
215-
```
216-
212+
4. The value of `1` is the resolved value of the function expression `abs(foo)`.
217213

218-
4. The value of `1` is the resolved value of the function expression
219-
220-
`abs(foo)`.
221214

222215
Below is the same steps for evaluating `abs(bar)`:
223216

224-
225217
1. Evaluate the input argument against the current data:
218+
```
219+
search(bar, {"foo": -1, "bar": 2"}) -> "2"
220+
```
226221

227-
```
228-
search(foo, {"foo": -1, "bar": 2"}) -> "2"
229-
```
230-
222+
2. Validate the type of the resolved argument.
223+
In this case `"2"` is of type `string` so immediately indicate that an
224+
`invalid-type` error occurred.
231225

232-
2. Validate the type of the resolved argument. In this case
233-
`"2` is of type `string` so the immediate indicate that
234-
an `invalid-type` error occurred.
235226

236227
As a final example, here is the steps for evaluating `abs(to_number(bar))`:
237228

238-
239229
1. Evaluate the input argument against the current data:
240-
241-
```
242-
search(to_number(bar), {"foo": -1, "bar": "2"})
243-
```
244-
245-
246-
2. In order to evaluate the above expression, we need to evaluate
247-
`to_number(bar)`:
248-
249-
```
250-
search(bar, {"foo": -1, "bar": "2"}) -> "2"
251-
# Validate "2" passes the type check for to_number, which it does.
252-
to_number("2") -> 2
253-
```
254-
255-
256-
3. Now we can evaluate the original expression:
257-
258-
```
259-
search(to_number(bar), {"foo": -1, "bar": "2"}) -> 2
260-
```
261-
262-
263-
4. Call the function with the final resolved value:
264-
265-
```
266-
abs(2) -> 2
267-
```
268-
230+
```
231+
search(to_number(bar), {"foo": -1, "bar": "2"})
232+
```
233+
This requires following the same process for `to_number(bar)`:
234+
1. Evaluate the input argument against the current data:
235+
```
236+
search(bar, {"foo": -1, "bar": "2"}) -> "2"
237+
```
238+
2. Validate the type of the resolved argument.
239+
In this case `"2"` is of type `string` so it passes the type check.
240+
3. Call the function with the resolved argument:
241+
```
242+
to_number("2") -> 2
243+
```
244+
4. The value of `2` is the resolved value of the function expression
245+
`to_number(bar)`.
246+
247+
2. Validate the type of the resolved argument.
248+
In this case `2` is of type `number` so it passes the type check.
249+
250+
3. Call the function with the final resolved argument:
251+
```
252+
abs(2) -> 2
253+
```
269254
270255
5. The value of `2` is the resolved value of the function expression
271-
`abs(to_number(bar))`.
256+
`abs(to_number(bar))`.
272257
273258
#### Examples
274259

0 commit comments

Comments
 (0)