Is there a difference between the keywords "for" and "as" in a loop macro?

In Common Lisp, in a loop macro, the keywords and and how look the same:

(loop for i from 1 to 3 do (print i))
(loop as i from 1 to 3 do (print i))

Is there any subtle difference I'm missing? If not, why bother with two different identical keywords?

+4
source share
1 answer

6.1.2.1 Iterative control :

Keywords forand asare synonyms; they can be used interchangeably .... By convention, forintroduces new iterations, and asintroduces iterations that depend on the previous iteration specification.

eg:.

(loop for x from 1 to 10
  as x2 = (* x x)
  as x4 = (* x2 x2)
  for y from 10 downto 1
  as y2 = (* y y)
  as y4 = (* y2 y2)
  sum (* x4 y4))

Why?

Tradition !:-)

And...

"... - , ... " / " ".

IOW, ( 6 ) , .

, , - " ".

+7

Source: https://habr.com/ru/post/1668037/


All Articles