Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: SRFI Support   [Contents][Index]


7.5.43 SRFI-105 Curly-infix expressions.

Guile’s built-in reader includes support for SRFI-105 curly-infix expressions. See the specification of SRFI-105. Some examples:

{n <= 5}                ⇒  (<= n 5)
{a + b + c}             ⇒  (+ a b c)
{a * {b + c}}           ⇒  (* a (+ b c))
{(- a) / b}             ⇒  (/ (- a) b)
{-(a) / b}              ⇒  (/ (- a) b) as well
{(f a b) + (g h)}       ⇒  (+ (f a b) (g h))
{f(a b) + g(h)}         ⇒  (+ (f a b) (g h)) as well
{f[a b] + g(h)}         ⇒  (+ ($bracket-apply$ f a b) (g h))
'{a + f(b) + x}         ⇒  '(+ a (f b) x)
{length(x) >= 6}        ⇒  (>= (length x) 6)
{n-1 + n-2}             ⇒  (+ n-1 n-2)
{n * factorial{n - 1}}  ⇒  (* n (factorial (- n 1)))
{{a > 0} and {b >= 1}}  ⇒  (and (> a 0) (>= b 1))
{f{n - 1}(x)}           ⇒  ((f (- n 1)) x)
{a . z}                 ⇒  ($nfx$ a . z)
{a + b - c}             ⇒  ($nfx$ a + b - c)

To enable curly-infix expressions within a file, place the reader directive #!curly-infix before the first use of curly-infix notation. To globally enable curly-infix expressions in Guile’s reader, set the curly-infix read option.

Guile also implements the following non-standard extension to SRFI-105: if curly-infix is enabled and there is no other meaning assigned to square brackets (i.e. the square-brackets read option is turned off), then lists within square brackets are read as normal lists but with the special symbol $bracket-list$ added to the front. To enable this combination of read options within a file, use the reader directive #!curly-infix-and-bracket-lists. For example:

[a b]    ⇒  ($bracket-list$ a b)
[a . b]  ⇒  ($bracket-list$ a . b)

For more information on reader options, See Scheme Read.


Next: , Previous: , Up: SRFI Support   [Contents][Index]