Re: Inconsistent loop behaviour when using threads.

Michał "phoe" Herda via Sbcl-help <[email protected]> Wed, 23 Apr 2025 15:14:41 +0200
Newsgroups gmane.lisp.steel-bank.general
Message-ID <[email protected]>
Rebind the variable I.

(make-thread (let ((i i)) (lambda () ...)))

On 23.04.2025 14:58, Lubwama Abdul Muswawir wrote:
> Hi, I am currently exploring the actor concurrent models in SBCL. The 
> loop macro is behaving wierdly when using threads inside it. Example loop:
>
> ```
> (eval-when (:compile-toplevel)
>   (defun test-p ()
>     (loop for i from 0 to 1000
>   do (make-thread (lambda () (format #.*terminal-io* "Working on: 
> ~a~%" i))))))
> ```
> This will print from 1 to 1001, it will work within expected bounds 
> when I use dolist, when I don't use threads. My use case involves 
> using threads on a range which I intended to generate via loop.
>
> This behaviour is consistent with all actor packages (sento, 
> lisp-actors) I have tried because all use sb-thread.
>
>
> _______________________________________________
> Sbcl-help mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sbcl-help

_______________________________________________
Sbcl-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-help