by epr · 3y ago · 0 comments
(defmacro cfor [initialize condition advance #* body]
`(do ~initialize
(while ~condition (do ~@body ~advance))))
(cfor (setv i 0) (< i 10) (+= i 1)
(print i))
This runs on the python vm with hy right now. Took about 2 mins to have it up and running after noticing this post on hn. Couldn't pass it up.My reply to the post was tongue in cheek. The point is that you can add on arbitrary language features to python using hy (any lisp, really). The syntax in question is normally referred to as an s-expression.
cfor(setv(i, 0), i < 10, i += 1) {
print(i)
}