Search code examples
schemeguilesrfi

SRFI notational conventions


I'm reading (looking at) the Guile Reference Manual but I do not understand some notational conventions specified by SRFI.

Note that the Guile Reference Manual seems to follow the structure of the SRFI documents. I browsed the source code on GuixSD to find some use cases without luck.

For example, I do not understand the meaning of kons and knil.

string-fold kons knil s [start [end]]

Hyperlinks: SRFI-13 or Guile Reference Manual

Q: Where are the Scheme notational conventions presented?


Solution

  • This notation for optional arguments is not only used here. It is also used in Unix program usage.

    string-fold kons knil s [start [end]]
    

    The content each bracket is optional.

    Means that it may be called as:

    string-fold kons knil s 
    string-fold kons knil s start
    string-fold kons knil s start end
    

    kons and knil are named such to denote their relationship with cons and nil where (string-fold cons nil s) <=> (string->list s) except that it can produce other structures than lists by providing a suitable cons like function and a nil value.