diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-11-10 08:16:54 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-11-10 08:16:54 -0800 |
commit | 67af8c39f31a738af98694375768192795f33ec4 (patch) | |
tree | e90224f015e97ccd35601ce465f24f830dfee2f8 /txr.1 | |
parent | ffac180e902b5e5bcf32872d6197b8c7800a2ed2 (diff) | |
download | txr-67af8c39f31a738af98694375768192795f33ec4.tar.gz txr-67af8c39f31a738af98694375768192795f33ec4.tar.bz2 txr-67af8c39f31a738af98694375768192795f33ec4.zip |
* match.c (v_fun): Bugfix: if there is material after
the function call, decline it; it is a horizontal context.
* txr.1: Discussion and examples of calls that are
in a horizontal context.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 63 |
1 files changed, 44 insertions, 19 deletions
@@ -2884,39 +2884,64 @@ it goes to the vertical one. Example: - Query: @(define which (x))@(bind x "horizontal")@(end) - @(define which (x)) - @(bind x "vertical") - @(end) - @(which fun) + Query: @(define which (x))@(bind x "horizontal")@(end) + @(define which (x)) + @(bind x "vertical") + @(end) + @(which fun) - Output: fun="vertical" + Output: fun="vertical" Not only does this call go to the vertical function, but it is in a vertical context. +If only a horizontal function is defined, then that is the one which is called, +even if the call is the only element in the line. This takes place in a +horizontal character-matching context, which requires a line of input which can +be traversed: + Example: - Query: @(define which (x))@(bind x "horizontal")@(end) - @(which fun) + Query: @(define which (x))@(bind x "horizontal")@(end) + @(which fun) + + Data: ABC - Data: ABC + Output: false - Output: false +The query failed. Why? Because since @(which fun) is in horizontal mode, +it matches characters in a line. Since the function body consists +of @(bind ...) which doesn't match any characters, the function +call requires an empty line to match. The line ABC is not empty, +and so there is a matching failure. The following +example corrects this: + +Example: -The query failed. Why? Because @(which fun) is in horizontal mode, -which means that it matches a line. What line does it match? -It matches the empty line. The reason is that the the call -@(which fun) contains only a @(bind ...) which doesn't match any -characters. In the following example, an empty line is supplied: + Query: @(define which (x))@(bind x "horizontal")@(end) + @(which fun) - Query: @(define which (x))@(bind x "horizontal")@(end) - @(which fun) + Data: <empty line> + + Output: fun="horizontal" + +A call made in a clearly horizontal context will ignore +the vertical definition, if any, and require the horizontal function. +In the next example, the call is followed by trailing material, +placing it in a horizontal context. Leading material will +do the same thing: + +Example: - Data: <empty line> + Query: @(define which (x))@(bind x "horizontal")@(end) + @(define which (x)) + @(bind x "vertical") + @(end) + @(which fun)B - Output: fun="horizontal" + Data: B + Output: fun="horizontal" .SS Nested Functions |