11 ms·
Funny, a macro serves the job you seek: (loop :for x :below 10 :do (print x)) This is a macro that presents a new abstraction/concept that's not
by reikonomusha 2y ago
Funny, a macro serves the job you seek:
(loop :for x :below 10
:do (print x))
This is a macro that presents a new abstraction/concept that's not "in AST format". It's a concept that's presented in syntax similar to any of the stock imperative languages.
That's the raison d'etre of macro: to expose these concepts/abstractions/etc. in a direct manner.
There are bad macros, to be sure, which are half-baked and underdocumented. That's no different a criticism from Python functions being 500 line god functions with boolean input flags, etc. Both cases are cases of bad code.
- germandiago 2y agoThe loop macro one remarkably flexible Lisp macro. One that it could do so many things that I just let it go. Probably I did not code enough Lisp, but I am not sure it is a good idea to go so complicated. Python as an example, iteration is a concept: go over a range of things. Complemented with comprehensions that can transform/filter with regular syntax that is always the same (if, f(x) or whatever). Comapre it to this: https://lispcookbook.github.io/cl-cookbook/iteration.html https://lispcookbook.github.io/cl-cookbook/iteration.html Is that worth the trouble, seriously? For sure it is super powerful (Python looping is quite powerful also). But what is the cognitive overhead of that, with custom syntaxes included?
- lispm 2y agoThat cookbook article is a bad example, especially for normal users, since instead of explaining idiomatic cases of iteration, it explains several iteration constructs (where some are extremely complex) in one article: loop, iterate, for, mapcar, series, transducers Built-in, of those above, are mapcar and loop. Python iteration isn't so much about ranges, I thought. See: https://kinsta.com/blog/iterables-in-python/ https://kinsta.com/blog/iterables-in-python/