[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: |
Eli Zaretskii |
Subject: |
Re: Is this a bug in while-let or do I missunderstand it? |
Date: |
Sun, 10 Nov 2024 08:22:17 +0200 |
> From: arthur miller <arthur.miller@live.com>
> CC: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
> Date: Sat, 9 Nov 2024 20:29:29 +0000
>
> In other words, there might be variables live outisde of
> the loop-scope we wish to access in the loop, and that is
> what Yuri's example shows. However, i,j are not re-initiated
> on each iteration, but remembers their value. The effecto of
> while-let in current implementation is that i,j are re-initiated
> in each iteration, not re-evaluated, if that makes it clear.
>
> I am not sure how to illustrate in a better way. The net effect is
> that lexical variables declared in while-let loop are "read-only".
>
> They are not, but since they are re-iniated, it is pointless to
> write to them.
You can write to them indirectly, if the evaluation is properly
written. If the evaluation is just assigning a fixed value to a
variable, then yes, writing to that variable in the body is pointless;
but then so is the use of while-let, IMO.
Even in your for-loop example from C, the CONDITION part of the loop
is re-evaluated on each iteration, and if you assign some fixed value
to the loop control variables there, your loop might become an
infloop, regardless of what you do in the body with those variables.
That's basically what the example of while-let you show at the
beginning of this discussion did.
> Of course, all loop predicates should be evaled on each iteration,
> but not re-iniated on each iteration. If that makes sense. Sorry,
> I am not very good at writing.
If while-let doesn't seem to do the job in some code of yours, then
don't use it there. Use something else. AFAIU, while-let was
introduced for those cases where its use makes sense and does the job
cleaner and clearer than the alternatives. It could be abused, of
course, but that's not necessarily its fault, is it?
Anyway, to get this long discussion back on track: is there a need to
clarify something in the documentation of while-let? if so, what?
- Re: Better documentation for non-binding clauses of if-let and friends, (continued)
- Re: Better documentation for non-binding clauses of if-let and friends, Alfred M. Szmidt, 2024/11/11
- Sv: [External] : Re: Is this a bug in while-let or do I missunderstand it?, arthur miller, 2024/11/10
- RE: [External] : Re: Is this a bug in while-let or do I missunderstand it?, Drew Adams, 2024/11/09
- RE: [External] : Re: Is this a bug in while-let or do I missunderstand it?, Drew Adams, 2024/11/09
- Re: Is this a bug in while-let or do I missunderstand it?, John ff, 2024/11/14
- 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?,
Eli Zaretskii <=
- Re: Is this a bug in while-let or do I missunderstand it?, Joost Kremers, 2024/11/10
- Re: Is this a bug in while-let or do I missunderstand it?, Alfred M. Szmidt, 2024/11/10
- Sv: Is this a bug in while-let or do I missunderstand it?, arthur miller, 2024/11/10
- 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?, Yuri Khan, 2024/11/11
- Sv: Is this a bug in while-let or do I missunderstand it?, arthur miller, 2024/11/11
- Re: Sv: Is this a bug in while-let or do I missunderstand it?, tomas, 2024/11/11
- Re: Is this a bug in while-let or do I missunderstand it?, Joost Kremers, 2024/11/11
- Re: Is this a bug in while-let or do I missunderstand it?, Eli Zaretskii, 2024/11/12
- Re: Is this a bug in while-let or do I missunderstand it?, Joost Kremers, 2024/11/12