29 ms·
Aren’t loops just wrappers around goto and if statements? The claim is that by expressing programs in terms of these array primitives, you (a) can have those p
by dan-robertson 3y ago
Aren’t loops just wrappers around goto and if statements?
The claim is that by expressing programs in terms of these array primitives, you (a) can have those primitives be super optimised and (b) better see what the program is actually about without worrying too much about eg what names to give all the loop counters, all the other intermediate state associated with iteration, etc.
- erik_seaberg 3y agoMost platforms make some kind of loop into a primitive, but in Common Lisp (dotimes (i 10) (print i)) is just a predefined macro that might expand into primitives like (BLOCK NIL (LET ((I 0)) (TAGBODY #:LOOP-2867 (IF (>= I 10) (GO #:END-2868)) (PRINT I) (PSETQ I (1+ I)) (GO #:LOOP-2867) #:END-2868 (RETURN-FROM NIL (PROGN NIL)))))