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 12:21:38 -0400 Message-ID: References: <87efws9w3c.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1492359711 3067 195.159.176.226 (16 Apr 2017 16:21:51 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 16 Apr 2017 16:21:51 +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 18:21:47 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 1czmvq-0000bM-Aq for ged-emacs-devel@m.gmane.org; Sun, 16 Apr 2017 18:21:46 +0200 Original-Received: from localhost ([::1]:32933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1czmvu-0001I6-7G for ged-emacs-devel@m.gmane.org; Sun, 16 Apr 2017 12:21:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1czmvl-0001Hq-1D for emacs-devel@gnu.org; Sun, 16 Apr 2017 12:21:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1czmvk-0005NE-3q for emacs-devel@gnu.org; Sun, 16 Apr 2017 12:21:41 -0400 Original-Received: from mail-oi0-x233.google.com ([2607:f8b0:4003:c06::233]:34693) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1czmvj-0005Mv-VF for emacs-devel@gnu.org; Sun, 16 Apr 2017 12:21:40 -0400 Original-Received: by mail-oi0-x233.google.com with SMTP id x184so36944663oia.1 for ; Sun, 16 Apr 2017 09:21:39 -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; bh=kaZp0Re1hkdoXVq6ujCorsq45YrWfIIav3EkLvEeRZs=; b=hGpHHMJ07iqze0ek37N1dTaMhwUu8B4RoVWP4b4ZBpNezL6Z98HXaYyMIOTKiAOSlw BGLWSfwuRhMGmSnH89h9M4+Hq/p9kPyhNh00MYBwwCMlB0XuVw3iR5glaVVuX+VTIi4g mTw++W9MEvs/CeHJQKcbaq0nvQxovLXUtPcYbG++z1BbkGB67aKfl8x2VnGofTfelsJK PzVZmByxceKfC8N1Dua4xY2OcTxCpLPCImi+hspA4gVbm5NSU5uZU10W0uzycGQu9SRY QPYCgPCdJdymGBfdiUOjH4JX4oxFgYWSgzc8KmdibTgV2HQxYCAiXnfZEHTvjlL2v6UI 0euA== 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; bh=kaZp0Re1hkdoXVq6ujCorsq45YrWfIIav3EkLvEeRZs=; b=i3NFNevO6h4vHdM9++j/Zgqi7U3Y03VjefxhM9lA89tJQWxi+rFTdKpDzsp8yRFGEC a5TCT2a/6hSbuWQvzbWTAIqWNzHBBoIXXQhtn8ph0FmPm/QqY+3z3WY8fbLJK0LMEfqc ZKWJwlPD6tbeU0hME2c8GQs+mioYVVcBwrbkpYIce5/9k9zCc3xdQObNpVSACaDN1/ax EWajSXzG5iT3YtKKUH9ap61HpNdQUrzybNs6RYzy2OKU/lXcmal8/2Lmw0Ajn3jMv2M+ T6JD1Aa6n1wmwMNKmq5ucu/RIUxxaCgiOp1/x87w+Y5sSOCWPXp0ZuNnbQfSqReeLggA 5o/g== X-Gm-Message-State: AN3rC/4Y8Yb5IhvKW2+tKWKMMgMkZdE8Iz43NVYUAWdYULe6qGmaQI7+ bhHCuFZfUP8nPBi8tHXFnJ+7hxgi6A== X-Received: by 10.157.7.169 with SMTP id 38mr2825766oto.221.1492359699300; Sun, 16 Apr 2017 09:21:39 -0700 (PDT) Original-Received: by 10.157.9.178 with HTTP; Sun, 16 Apr 2017 09:21:38 -0700 (PDT) In-Reply-To: <87efws9w3c.fsf@ericabrahamsen.net> X-Google-Sender-Auth: dPRpCj_iPeO9Dvcx2U57m4wEfDM X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::233 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:214011 Archived-At: On Sun, Apr 16, 2017 at 12:05 PM, Eric Abrahamsen wrote: > I'm trying to do something that seems like it would be a normal use > case: spawn a series of threads which call the same function using > different external processes. Practically what this means is that I want > to pass a function-plus-argument form to make-thread, not a function > symbol. Something like: > > (let* ((results) > (sources '(source1 source2)) > (threads > (mapcar > (lambda (s) > (make-thread > (funcall > (lambda () > (push (get-stuff-from-source s) results))))) > sources))) > (mapc #'thread-join threads) > results) > > The (funcall (lambda () thing was the only way I could get anything but > nil out of the thread functions. I think I'm fooling myself, though: so > far as I can tell, `get-stuff-from-source' is fully evaluated before the > thread is made, and nothing at all happens during the #'thread-join > loop. Just drop the funcall: (make-thread (lambda () ...)) should do what you want, assuming you have lexical-binding set (if not, you can construct a lambda-list with backquote or similar).