From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.devel Subject: Re: make-thread with lambda form instead of function symbol Date: Sun, 16 Apr 2017 14:44:25 -0400 Message-ID: References: <87efws9w3c.fsf@ericabrahamsen.net> <874lxo6x4e.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1492368311 626 195.159.176.226 (16 Apr 2017 18:45:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 16 Apr 2017 18:45:11 +0000 (UTC) Cc: Emacs developers To: Eric Abrahamsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 16 20:45:06 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1czpAW-0008T6-Sv for ged-emacs-devel@m.gmane.org; Sun, 16 Apr 2017 20:45:04 +0200 Original-Received: from localhost ([::1]:33280 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1czpAc-00038V-MN for ged-emacs-devel@m.gmane.org; Sun, 16 Apr 2017 14:45:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1czpA0-00038O-KY for emacs-devel@gnu.org; Sun, 16 Apr 2017 14:44:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1czp9x-0004e8-1s for emacs-devel@gnu.org; Sun, 16 Apr 2017 14:44:29 -0400 Original-Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:35038) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1czp9w-0004bD-Sg for emacs-devel@gnu.org; Sun, 16 Apr 2017 14:44:28 -0400 Original-Received: by mail-oi0-x236.google.com with SMTP id f22so126265575oib.2 for ; Sun, 16 Apr 2017 11:44:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=MgTiey3je1iHlPcIHDYQQelIAkgPAeu4TuQ/kYvOLlk=; b=Q+QqMsn0QhW6vzza+EOFssXSxIRmKpZ7ClwF2lVYiXbUwu0PjcQg9ygi2c3sMwOZCF zHwULplawe5UnS3/kxLptfZtGXi8QWcmnuujj3vw8Tw47goCBkHE5wVw7TBnyRsO55cV Pg9kj7Y+/7UVit1ZmlgU3VaibFZyd6QGFIfp7eM88C+31gbh5IROnpyAhUgtyTeZnrP7 GPEHSh8bCfgOZu7ykXOC+tVGg2Iwy/k2hgLg0lZ6vssJURav0rHI2EvExOIT624B6W0o w2BdVXhXolPlYogNXcmC6Oa0V9Cdk+iJIDhMmJs9mgTE6VwEG9sLPAoPvouKIN6iezz3 eL2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=MgTiey3je1iHlPcIHDYQQelIAkgPAeu4TuQ/kYvOLlk=; b=oUq3FP2LHBMzZQCqDuJKo0pBy2sCUOhgWFhJQClYJ6jXsqqZAb5xQT0A6suP33N1Yy N4wVcGXWIHdi98LgOeYUuTOrxXdISU9HjUgHq1lsheI3iceBhvRUBCaosM7Dc2Ma5t8l ePAKYmx0CzcywmGZexCR4n9DJVXHu5/zVvWB+jfAGn1d4uX2+Xk0ptfxRD6F963o7Q+V Dk5Tzs0mQs4lMbRvOqTb5dgzlXJ/9zpr3bQVwkbExxHSOMYtBEp7TyTXWq4v1eenXssI JL99LTM5/JzpKePwcwBnLC79KTKUuKv94ixXzW1/MylCfwAkm9sraGPpi0cwvCtGkIJ8 mHOg== X-Gm-Message-State: AN3rC/5NAVdaKGhkASksxJP5s1IQr6ZTQvAao3DWnW5Rl/eTFO86ykKf KoLSwqvzqgT3009qXLG1nIU2prBCUg== X-Received: by 10.157.38.248 with SMTP id i53mr2952605otd.55.1492368265777; Sun, 16 Apr 2017 11:44:25 -0700 (PDT) Original-Received: by 10.157.9.178 with HTTP; Sun, 16 Apr 2017 11:44:25 -0700 (PDT) In-Reply-To: <874lxo6x4e.fsf@ericabrahamsen.net> X-Google-Sender-Auth: l-5eCqgIUZ-XR6p7YvYOV28vsI8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::236 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:214019 Archived-At: On Sun, Apr 16, 2017 at 2:11 PM, Eric Abrahamsen wrote: > > (setq lexical-binding t) > > (let ((threads > (mapcar > (lambda (el) > (make-thread > (lambda () > (push (cl-incf el) results)))) > '(1 2 3))) > results) > (mapc #'thread-join threads) > results) > > This gives me nil. > > (Incidentally, if I put this in a function and edebug it, it tells me > edebug will stop at the next break point, and then enters a level of > recursive editing I can't escape from: C-M-c gives me "No catch for tag: > exit, nil".) > > Should the above example work? No, check the compile warnings: a.el:7:33:Warning: reference to free variable =E2=80=98results=E2=80=99 a.el:9:7:Warning: assignment to free variable =E2=80=98results=E2=80=99 Not sure about the edebug thing, probably it doesn't handle cross-thread stepping. The below returns (2 3 4) or sometimes (3 4 2). (let* ((results nil) (threads (mapcar (lambda (el) (make-thread (lambda () (push (cl-incf el) results)))) '(1 2 3)))) (mapc #'thread-join threads) results)