[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is this a bug in while-let or do I missunderstand it?
From: |
Alfred M. Szmidt |
Subject: |
Re: Is this a bug in while-let or do I missunderstand it? |
Date: |
Tue, 12 Nov 2024 12:55:33 -0500 |
> The scope of the let-binding is the same in both.
I don't see how. With `while`, `result` is let-bound outside the loop, with
`while-let` it's bound inside the loop, even after macroexpanding it:
And that is (again) the crux of the matter, one group thinks it is LET
bound outside of the loop, another inside.
Consider this, which will pass nil to BAR, but also reassign RESULT to
whatever FOO returns each iteration; which is the part that is
confusing for those who consider LET to be the binding and scope of
the variables (this also makes it much harder to debug code I think).
(while-let ((result (foo)))
(setq result nil)
(bar result))
Which expands to:
(catch 'done18
(while t
(let* ((result (and t (foo))))
(if result
(progn
(setq result nil)
(bar result))
(throw 'done18 nil)))))
Mind you, what you want to do can still be done with `while-let`, provided
you establish the relevant binding *outside* the loop:
Then what point is while-let? Should there be a let-while? And a
let-while-let? There are 20 occurences of while-let in Emacs ...
- Re: Is this a bug in while-let or do I missunderstand it?, (continued)
- Re: Is this a bug in while-let or do I missunderstand it?, John ff, 2024/11/14
- Re: Is this a bug in while-let or do I missunderstand it?, John ff, 2024/11/14
- Re: Sv: Is this a bug in while-let or do I missunderstand it?, Joost Kremers, 2024/11/09
- Sv: Sv: Is this a bug in while-let or do I missunderstand it?, arthur miller, 2024/11/10
- Re: Is this a bug in while-let or do I missunderstand it?, Andreas Schwab, 2024/11/10
Re: Is this a bug in while-let or do I missunderstand it?, arthur miller, 2024/11/12
Sv: Is this a bug in while-let or do I missunderstand it?, arthur miller, 2024/11/13
Re: Is this a bug in while-let or do I missunderstand it?, arthur miller, 2024/11/12