From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Wiegley Newsgroups: gmane.emacs.devel Subject: Re: async.el: A simple asynchronous framework for Emacs Date: Tue, 19 Jun 2012 19:53:47 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1340153690 26006 80.91.229.3 (20 Jun 2012 00:54:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 20 Jun 2012 00:54:50 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 20 02:54:49 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Sh9C4-0004E0-VM for ged-emacs-devel@m.gmane.org; Wed, 20 Jun 2012 02:54:49 +0200 Original-Received: from localhost ([::1]:33941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sh9C4-00008n-VB for ged-emacs-devel@m.gmane.org; Tue, 19 Jun 2012 20:54:48 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:43426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sh9C2-00008U-Dk for emacs-devel@gnu.org; Tue, 19 Jun 2012 20:54:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sh9C0-0008Nr-Nt for emacs-devel@gnu.org; Tue, 19 Jun 2012 20:54:45 -0400 Original-Received: from mail-gh0-f169.google.com ([209.85.160.169]:61066) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sh9C0-0008Nj-GX for emacs-devel@gnu.org; Tue, 19 Jun 2012 20:54:44 -0400 Original-Received: by ghrr18 with SMTP id r18so5999190ghr.0 for ; Tue, 19 Jun 2012 17:54:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:references:mail-followup-to:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=JKZnAC4LVOL1t6MwHJepHqMjbtFoYhmtSJkg/FHW6CU=; b=eYph2HaHvXNKEnvf5PeLZU6w1ysbg/PIp6piKpK8XKc9yi/LXBCdUGw6ixkl8WY/3r 4QiRgkglhT8gDs8roHXhqjRxemfWLDMg8YnQCdZkVeNCQI00qwxiazyTsiSSdliKR4d2 Vd21rxJIRywAn7AFKHwUIO3IMoNk7ySKzY0vdC/YKvuiof6IhkfxiqoCLEaAA8uGUNDL 4D7FFJjYjhJyM5i+9J9AQfmVpbP9aS+ogkSZMK1hu3fx4/xlO4Mi25CfVLDIEzFRclVF lX0MclcsMNDUYqJUj8XYqHciwnV7TY4Y6dKkGmvgF9XxkWBHWGKzFVkmXAmWJlrCArMA 9E9Q== Original-Received: by 10.50.104.170 with SMTP id gf10mr2915009igb.52.1340153682337; Tue, 19 Jun 2012 17:54:42 -0700 (PDT) Original-Received: from vulcan.local (c-98-215-105-167.hsd1.il.comcast.net. [98.215.105.167]) by mx.google.com with ESMTPS id if4sm13680807igc.10.2012.06.19.17.54.41 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 19 Jun 2012 17:54:41 -0700 (PDT) Original-Received: by vulcan.local (Postfix, from userid 501) id A72CBEFBECE3; Tue, 19 Jun 2012 19:53:47 -0500 (CDT) Mail-Followup-To: emacs-devel@gnu.org In-Reply-To: (John Wiegley's message of "Tue, 19 Jun 2012 19:20:16 -0500") User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (darwin) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:151038 Archived-At: Apropos of nothing, just discovered that `apply-partially' is a nice way to run one-liners asynchronously: (async-start (apply-partially #'copy-file from to ok-flag preserve-time) (apply-partially #'message "Copy done: %s -> %s" from to)) The alternative is less consistent: (async-start `(lambda () (copy-file ,from ,to ,ok-flag ,preserve-time)) (lambda () (message "Copy done: %s -> %s" from to))) Since `form' and `to' need their values passed to the child process, while the variables remain in scope for the callback (thanks to closures). Of course, the <24 version is equally consistent in its ugliness: (async-start `(lambda () (copy-file ,from ,to ,ok-flag ,preserve-time)) `(lambda () (message "Copy done: %s -> %s" ,from ,to))) John