**diff options**

author | dieggsy <dieggsy@protonmail.com> | 2019-10-29 21:27:58 -0400 |
---|---|---|

committer | dieggsy <dieggsy@protonmail.com> | 2019-10-29 21:27:58 -0400 |

commit | 9c85e5d909682461d9dc4dcfc12390aaaf97f7c9 (patch) | |

tree | 627f7ee8e1f345450ea85df54089c3e4b44179c0 | |

parent | 167c145fb67b8b341917962b7760a60f0e89d843 (diff) | |

download | srfi-105-9c85e5d909682461d9dc4dcfc12390aaaf97f7c9.tar.gz |

Add documentation for recent changes

-rw-r--r-- | srfi-105.svnwiki | 80 |

1 files changed, 68 insertions, 12 deletions

diff --git a/srfi-105.svnwiki b/srfi-105.svnwiki index 7780c12..2d2d329 100644 --- a/srfi-105.svnwiki +++ b/srfi-105.svnwiki @@ -12,7 +12,8 @@ Curly infix expressions. For more information, see The core srfi as specified in [[http://srfi.schemers.org/srfi-105/srfi-105.html|SRFI-105]]. Note that the -srfi does not on its own handle mixed operators. +srfi does not on its own handle mixed operators or square-bracket neoteric +expressions. ===== Notes ====== Dot notation @@ -29,21 +30,67 @@ inside curly braces. ====== Neoteric expressions -n-expressions (neoteric expressions) inside cruly braces (e.g. {{f(x)}}) are -not currently supported. +In part due to the way that Chicken's reader {{##sys#read}} is implemented, and +in part becasue of the way neoteric-expression (n-expression) support is +implemented, n-expressions inside curly braces (e.g. {{f(x)}}) are only +partially supported. In particular, they will work as long as the n-expression +is not nested directly within a lisp expression. However, this can be worked +around by adding curly brackets directly around the n-expression. + +To show what this means, here are some (non-exhaustive) examples: + +DOES work - simple n-expressions: + +* {{{f(x)} ⇒ (f x)}} +* {{{f(x) + 1} ⇒ (+ (f x) 1)}} +* {{{3 + f(x) + g(x)} ⇒ (+ 3 (f x) (g x))}} + +DOES work - nested/chained n-expressions: + +* DOES work: {{{f(x)(y)(z)} ⇒ (((f x) y) z)}} +* DOES work: {{{3 + 4 + f(x)(y)(z)} ⇒ (+ 3 4 (((f x) y) z))}} +* DOES work: {{{f(g(h(x)))} ⇒ (f (g (h x)))}} +* DOES work: {{{f(g(h(x))) * 5 * 3} ⇒ (* 5 3 (f (g (h x))))}} +* DOES work: {{{f(g(h(x)))(y)} ⇒ ((f (g (h x))) y)}} +* DOES work: {{{f(g{h(x) + 1})} ⇒ (f (g (+ (h x) 1)))}} + +DOES NOT work - n-expressions nested inside lisp syntax: + +* {{{ (f (g h(x))) } ⇒ (f (g (h x)))}} - use {{{ (f (g {h(x)})) }}} instead +* {{{#(1 2 f(a) 4)} ⇒ #(1 2 (f a) 4)}} - use {{{#(1 2 {f(a)} 4)}}} instead +* {{{(f #;g(x) h(x))} ⇒ (f (h x))}} - no workaround available +* Any of the above working neoteric expressions within any lisp syntax - enclose them with additional curly brackets instead. + +===== Further details + +n-expression support is implemented by locally modifying the internal +{{##sys#read}} procedure which is not itself recursive, but rather uses an +internal (and inaccesible) recursive read procedure. This means any +modifications made to {{##sys#read}} procedure cannot take effect inside lisp +expressions, as the internal recursive read handles those and has no knowledge +of the modifications. + +The internal read procedure does however have knowledge of special read syntax, +which is why this limitation can be 'escaped' with more curly bracket +expressions. + +This could potentially be worked around with a solid parser, but is a little +out of the scope of this extension. ==== srfi-105.extra -Adds support for mixed operators. Importing this implies {{(import srfi-105)}}, -so one should not have to import both. {{$nfx$}} as specified in the original -SRFI document is implemented as syntax in order to be able to handle syntax -operators like {{and}}, {{or}}, and some of the aliases defined in this module. +Adds support for mixed operators and square bracket neoteric expressions. +Importing this implies {{(import srfi-105)}}, so one should not have to import +both. {{$nfx$}} as specified in the original SRFI document is implemented as +syntax in order to be able to handle syntax operators like {{and}}, {{or}}, and +some of the aliases defined in this module. ===== Usage -Upon importing this module, curly infix expressions with mixed operators should -just work. Certain operators are handled specially by default. See -{{mixed-operator-precedence}} for more information. +Upon importing this module, curly infix expressions with mixed operators as +well as neoteric calls of the form {{x[a]}} should just work. Certain operators +are handled specially by default. See {{mixed-operator-precedence}} for more +information. ===== Notes ====== Unary operators in mixed expressions @@ -53,6 +100,12 @@ something like {{ {#t and not #f} }} should result in an error. To use unary operators, use lisp syntax ({{ {#t and (not #f)} }}) or n-expressions {{ {#t and not(#f)} }}. +====== Neoteric square bracket expressions + +Square bracket n-expressions such as {{a[x]}} are handled using SRFI-123's +{{ref*}}. See [[https://wiki.call-cc.org/eggref/5/srfi-123|srfi-123]] for more +information. + ===== Precedence <parameter>(mixed-operator-precedence)</parameter> @@ -152,8 +205,9 @@ An alias for boolean {{not}}. ===== Special symbols In general, you shouldn't need to use the following directly, as curly -expressions containing mixed operators will simply automatically expand into -{{($nfx$ ...)}} +expressions containing mixed operators or neoteric calls of the form {{x[a]}} +will simply automatically expand into {{($nfx$ ...)}} or {{($bracket-apply$ +x a)}}, respectively. <syntax>($nfx$ . rest)</syntax> @@ -194,6 +248,8 @@ SOFTWARE. === Version History +; 0.1.6 : Add simpler and more robust neoteric expression support +; 0.1.5 : Rewrite curly expression reader more in accordance with reference ; 0.1.5 : Rewrite curly expression reader more in accordance with reference ; 0.1.4 : Temporarily drop neoteric expression support ; 0.1.3 : Rename extras module to srfi-105.extra |