From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: Proposal for a new (ice-9 history) Date: Mon, 29 Oct 2018 20:25:40 -0400 Message-ID: <87lg6gmg9s.fsf@netris.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1540859080 6365 195.159.176.226 (30 Oct 2018 00:24:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2018 00:24:40 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: guile-devel To: Mikael Djurfeldt Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Oct 30 01:24:36 2018 Return-path: Envelope-to: guile-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 1gHHpj-0001Xe-0s for guile-devel@m.gmane.org; Tue, 30 Oct 2018 01:24:35 +0100 Original-Received: from localhost ([::1]:49830 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHHrp-00019L-Af for guile-devel@m.gmane.org; Mon, 29 Oct 2018 20:26:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHHrl-00019G-Al for guile-devel@gnu.org; Mon, 29 Oct 2018 20:26:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHHri-0001ZL-4V for guile-devel@gnu.org; Mon, 29 Oct 2018 20:26:41 -0400 Original-Received: from world.peace.net ([64.112.178.59]:33410) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHHre-0001Wx-Fb for guile-devel@gnu.org; Mon, 29 Oct 2018 20:26:35 -0400 Original-Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gHHrU-0000jz-Fb; Mon, 29 Oct 2018 20:26:24 -0400 In-Reply-To: (Mikael Djurfeldt's message of "Mon, 29 Oct 2018 15:13:20 +0100") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.112.178.59 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19699 Archived-At: Mikael Djurfeldt writes: > The interface of (value-history) would instead have a lazy-binder > which provides a syntax transformer for every $... actually being > used. The $... identifier would expand into a list-ref into the value > history. A few more suggestions: If I write (define (foo x) (+ $$0 x)) at the repl, then I expect 'foo' to continue to refer to the same entry in the value history, even after the value history is later extended. I'm also a bit concerned about the efficiency implications of expanding these variable references into 'list-ref' calls when the history grows large. If I write a loop that evaluates $$0 a million times, I'd prefer to avoid a million 'list-ref' calls. To address these concerns, I'd like to suggest a slightly different approach: * $0, $1, ... would continue to be ordinary variable bindings in (value-history), as they are now. * The 'count' in 'save-value-history' would be made into a top-level variable in (ice-9 history). * $$0, $$1, $$2, ... would be handled by a lazy-binder, providing a syntax transformer that looks at the value of 'count' at macro expansion time, and expands into the appropriate variable reference $N. For example, if $5 is the most recent value, $$0 would expand into $5 instead of (list-ref ...). This would eliminate my concerns over efficiency. What do you think? Mark