[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Suggestion: nix VALUES in favor of DOT

This page is part of the web mail archives of SRFI 71 from before July 7th, 2015. The new archives for SRFI 71 contain all messages, not just those from before July 7th, 2015.

The current draft of the srfi says:

  let-values suffers from "parenthesis complexity"

The proposed syntax fixes the parenthesis complexity for fixed-arity
cases, but it clearly still suffers from parenthesis complexity in the
variable-arity case.  As proof of this, I offer the fact that the
syntax's own designer screwed up the parentheses in two out of three
of the examples given for variable-arity clauses:

  The syntactic keyword values allows receiving all values as in (let
  ((values . xs) (foo x)) body). It also allows receiving no values at
  all as in (let ((values) (for-each foo list)) body).

Those should be (let (((values . xs) (foo x))) body) and (let
(((values) (for-each foo list))) body), according to the specification
given later in the srfi.

To avoid that mentally taxing triple-open-paren, you could use a
keyword named DOT rather than VALUES, with a syntax like so:

  (let ((a b dot c (unlist '(1 2 3 4)))) c)  =>  (3 4)

  (let ((dot x (unlist '(1 2 3 4)))) x)      =>  (1 2 3 4)

I don't think you need a special case for exactly zero values, because
that's a fixed-arity case.  Why not allow this?:

  (let ((<zero-valued-expression>)) <body>)

Here's some BNF:

  <binding spec> --> (<variable>* <expression>)
  <binding spec> --> (<variable>* dot <variable> <expression>)

Whether or not DOT would be the best choice of identifier for this, I
don't know.  Here are the identifiers I considered: