FOR loop decrementing #2318
Answered
by
nbriggs
RyanBurnside
asked this question in
Q&A
Replies: 4 comments 2 replies
-
|
It works for me by defining the function with SEdit:
But also when defining it with
With
|
Beta Was this translation helpful? Give feedback.
1 reply
-
|

If you expand (meta-x in sedit is one way) your function with a for loop, you can see what it's really doing. This is FOO above --
(LAMBDA NIL (* ; "Edited 18-Oct-2025 09:40 by briggs")
(PROG (($$TEM3 0)
$$VAL $$TEM2 $$TEM1 (I 3))
$$LP
(COND ((LESSP I $$TEM3)
(GO $$OUT)))
(SETQ $$TEM1 I)
(COND ($$TEM2 (FRPLACD $$TEM2 (SETQ $$TEM2 (LIST $$TEM1))))
(T (SETQ $$VAL (SETQ $$TEM2 (LIST $$TEM1)))))
$$ITERATE
(SETQ I (PLUS I -1))
(GO $$LP)
$$OUT
(RETURN $$VAL)))
What I'm guessing is that you didn't have constants in the FOR loop in your function case, so it assumed a default positive increment, which will indeed not perform any iterations, being the equivalent of
2/20_ (FOR I FROM 3 TO 1 BY 1 COLLECT I)
NIL
2/21_ (FOR I FROM 3 TO 1 BY -1 COLLECT I)
(3 2 1)
…-- Nick
On Oct 17, 2025, at 23:57, Ryan Burnside ***@***.***> wrote:
Hello,
I've noticed that in the InterLisp Exec I can run something like
(FOR I FROM 3 TO 0 COLLECT I)
giving (3 2 1 0)
While in a saved function it simply doesn't loop.
I know InterLisp features CLISP but do these things ONLY work in the Exec?
I tried defining the function with DEFINEQ as well in the Exec but even there, it was not corrected as it is outside the DEFINEQ definition.
It's a bit annoying that code can work in the Exec but then suddenly has totally different behavior when used in a function. BUT part of learning a new system is to of course accept the way it works.
Sincerely,
Ryan
—
Reply to this email directly, view it on GitHub <#2318>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB6DAWIM4TLNJNRMDVM77AL3YHQEZAVCNFSM6AAAAACJRJM43SVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZZGAZTSOJQGI>.
You are receiving this because you are subscribed to this thread.
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
RyanBurnside
-
|
Ah, thanks for the tip about macro expansion. Here is what I had prior.
|
Beta Was this translation helpful? Give feedback.
1 reply
-
|
When CLISP was being developed by Warren Teitelman, the desires for ease of
use vs. consistent and predictable results were in some flux.
Interlisp is more 'forgiving' in lots of ways, even when the forgiving
behavior is a little too loose.
We see this conflict in lots of places but it's rarely pointed out in the
documentation.
pathnames vs. symbols vs. strings for files, coercion of fonts and font
names and other ways of indicating the desired font....
there are hundreds of cases. DWIM isn't a 'feature' as much as it is a
philosophy.
https://LarryMasinter.net https://interlisp.org
…On Sat, Oct 18, 2025 at 11:34 AM Ryan Burnside ***@***.***> wrote:
Thanks for testing it.
I didn't realize that using a parameter from outside the for loop would
cause the bad behavior for the starting value.
—
Reply to this email directly, view it on GitHub
<#2318 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIQTKYLESEQ363DT3ZRJLL3YKBZ5AVCNFSM6AAAAACJRJM43SVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTINZRHAZTOMY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment




Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I've noticed that in the InterLisp Exec I can run something like
giving (3 2 1 0)
While in a saved function it simply doesn't loop.
I know InterLisp features CLISP but do these things ONLY work in the Exec?
I tried defining the function with DEFINEQ as well in the Exec but even there, it was not corrected as it is outside the DEFINEQ definition.
It's a bit annoying that code can work in the Exec but then suddenly has totally different behavior when used in a function. BUT part of learning a new system is to of course accept the way it works.
Sincerely,
Ryan
Beta Was this translation helpful? Give feedback.
All reactions