4 ms·
> return/if/while/break/continue actually work in Hylang. Common Lisp doesn't have these. It has all of them! Return: CL-USER> (defun foo () (return-from
by zeveb 8y ago
> return/if/while/break/continue actually work in Hylang. Common Lisp doesn't have these.
It has all of them!
Return:
CL-USER> (defun foo () (return-from foo 1) 2)
→ FOO
CL-USER> (foo)
→ 1
If:
CL-USER> (if t 1 2)
→ 1
CL-USER> (if nil 1 2)
→ 2
While:
CL-USER> (let ((x t))
(loop for j from 1 to 10
while x
do (when (= j 3)
(setf x nil))
collect j))
→ (1 2 3)
Break:
CL-USER> (loop for i from 1 to 10 do (format t "~&i: ~a~%" i) when (> i 4) do (return) do (format t "~& -~%"))
i: 1
-
i: 2
-
i: 3
-
i: 4
-
i: 5
→ NIL
Continue:
CL-USER> (do ((i 1 (1+ i)))
((> i 10))
(format t "~&i: ~a~%" i)
(when (= i 4) (go end))
(format t "~& -~%")
end)
i: 1
-
i: 2
-
i: 3
-
i: 4
i: 5
-
i: 6
-
i: 7
-
i: 8
-
i: 9
-
i: 10
-
→ NIL
Common Lisp has goto, has traditional control structures and can be as imperative as you like.
- foobar_ 8y agoI made a mistake of mentioning Common Lisp in the same line. Common Lisp has pointers (cons) as well. Hylang doesn't have goto, as Python doesn't have it. Well you can always implement a goto by having 1. A list made of lambdas. List gives numeric addresses. Dict will give you named addresses. 2. Pass the above list itself to each of the lambda or make it a global variable called ADDRESSES. No one talks about the cool imperative features of Common Lisp right ? The was the point I was trying to make. Scripting is imperative. Python is a scripting language .. right ? That makes Hylang a scripting language too. Hylang is (Python).