SRFI 156: Syntactic combiners for binary predicates Arthur A. Gleckler 10 Jul 2017 21:06 UTC

Scheme Request for Implementation 156,
"Syntactic combiners for binary predicates,"
by Panicz Maciej Godek,
is now available for discussion.

Its draft and an archive of the ongoing discussion are
available at <>.

You can join the discussion of the draft by filling out the
subscription form on that page.

You can contribute a message to the discussion by sending it
to <>.

Here's the abstract:

  The power and universality of the prefix notation employed
  by Scheme and other dialects of Lisp can be intimidating.
  However, we find that there are occasions when prefix
  syntax can be confusing and lead to code that is not
  self-documenting.  We have identified that one of such
  cases is the use of asymmetrical binary predicates.

  Probably the most common examples are the numerical
  comparison predicates <, <=, >= and >.  It is non obvious,
  for instance, how the expression (< a b) should be

  The problem gets more serious in the case of user-defined
  binary predicates.  For example, in the expression
  (divides?  x y) the role of arguments is unclear: we don't
  know whether the author of the divides? predicate intended
  it to check whether x divides y or whether y divides x.

  And while there seems to exist a silent convention among
  Schemers to interpret predicates like (has-something-to? x
  y) as "x has something to y", we believe that this
  convention should be made explicit, and confirmed by the
  forms available in the language.

  We therefore propose a thin layer of "syntactic stevia"
  that can be implemented using regular Scheme macros.  We
  suggest, that the code (is x < y) should be transformed to
  (< x y), and (is x < y <= z) -- to (and (< x y) (<= y z)).
  In addition, we suggest special meaning to the _ symbol:
  (is _ < y) and (is x < _) should be transformed to (lambda
  (_) (< _ y)) and (lambda (_) (< x _)), respectively.  This
  SRFI document also describes some other uses of the is
  macro and its limitations.


SRFI Editor