Subject: bug#28254: 26.0.50; SRFI-2 and-let*

From: Michael Heerdegen <[email-masked]>
Date: Tue, 12 Sep 2017 20:44:11 +0200

Mark Oteiza <[email-masked]> writes:

> > Not really related to your change, but: Maybe we should additionally
> > say that THEN can refer to the bindings made in the VARLIST, but
> > ELSE to none, not even to those that resulted in non-nil values
> > before "failing".
>
> That's not true though--you can refer to the bindings in either branch:

Hmm, that feels strange.  FWIW, all the scheme implementations I looked
at implemented it in a way that binding variables stops after the first
nil.  OTOH I would expect that all bindings are only available from the
THIS branch (this is my personal opinion).  In our case, we have
something third: always all bindings are visible in the ELSEs, e.g.

(let ((z 1))
  (if-let* ((nil) (z 100))
      (doesnt-matter)
    z))

==> nil

That doesn't feel right.

I have two more questions:

In `internal--listify':

(defsubst internal--listify (elt)
  "Wrap ELT in a list if it is not one.
If ELT is of the form ((EXPR)), listify (EXPR) with a dummy symbol."
  (cond
   ((symbolp elt) (list elt elt))
   ((and (null (cdr elt))
         (let ((form (car elt)))
           (or (listp form) (atom form))))
    (list (make-symbol "s") (car elt)))
   (t elt)))

isn't (or (listp form) (atom form)) always true?

Secondly, in `internal--build-binding-value-form':

(defsubst internal--build-binding-value-form (binding prev-var)
  "Build the conditional value form for BINDING using PREV-VAR."
  (let ((var (car binding)))
    (if (and (null (cdr binding)) (atom (car binding)) (not (symbolp (car binding))))
        `(,var (and ,prev-var ,var))
      `(,var (and ,prev-var ,(cadr binding))))))

how can it happen that (car binding) is an atom but not symbolp?  And if
(car binding) == var is not a symbol, how does the returned binding make
sense?

Thanks,

Michael.