From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.devel Subject: Re: Proposal for a new (ice-9 history) Date: Tue, 30 Oct 2018 02:08:19 +0100 Message-ID: References: <87lg6gmg9s.fsf@netris.org> Reply-To: mikael@djurfeldt.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000027b43d057967d373" X-Trace: blaine.gmane.org 1540861605 18440 195.159.176.226 (30 Oct 2018 01:06:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2018 01:06:45 +0000 (UTC) Cc: guile-devel To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Oct 30 02:06:40 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 1gHIUS-0004g6-JW for guile-devel@m.gmane.org; Tue, 30 Oct 2018 02:06:40 +0100 Original-Received: from localhost ([::1]:49966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHIWY-0000jl-JZ for guile-devel@m.gmane.org; Mon, 29 Oct 2018 21:08:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHIWQ-0000jg-Bv for guile-devel@gnu.org; Mon, 29 Oct 2018 21:08:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHIWM-00086D-Aq for guile-devel@gnu.org; Mon, 29 Oct 2018 21:08:42 -0400 Original-Received: from mail-ot1-f52.google.com ([209.85.210.52]:40099) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHIWK-00084e-Vx for guile-devel@gnu.org; Mon, 29 Oct 2018 21:08:37 -0400 Original-Received: by mail-ot1-f52.google.com with SMTP id m15so9524998otl.7 for ; Mon, 29 Oct 2018 18:08:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=EdxvwgJW5CgVNDy/Lz79C3LgwGOEGWn8s5D5rqqA9Vs=; b=GKO0s1vPJT+yKwMjxmWOHKO4vZPah1UPo8bvzZEdj4Yx+u0SujCdz5dvMK9/2/WfP1 1s+RaFxnOITrTi9cjfCwgqWb8PPdxN6lrezpcC+eiKz4BM7pZIEWkH20pK67udlNQPN/ 1SRfd6lySZJbLRijjrXcfhE7NsU7LQzQGG5+YgovxOm7kG7yCshAhPwM80W8mDKJaD1m Eni+ecbsg6YHhkrhGP6aKjbTB086hm1BaFPhjG7TKJxIwJrsCgWnKxapQvBj567d6b4o HqMdK95eGQexApLxZX5isHgcHoTlyv6+d1IfZfGQp+UJt/6j1vjJH8vE+SxSupW+zGjL kGHA== X-Gm-Message-State: AGRZ1gKzgsO2deZM3Dqr3lEI98i/vKHLnmF9nTOAiTHvvHLS+6mx0XPF mmqXVMnH51ypmznFX/G/w82aqMNLKM43h8iU3W0= X-Google-Smtp-Source: AJdET5fe6ct9cxjLgaE0cvTqrIa2v1/e0zmp6db0H70TWeGryxt2VZ56L/1oNr6NHeXY882JmZk5oD3046MN5YS99Qs= X-Received: by 2002:a9d:213b:: with SMTP id i56mr4296557otb.40.1540861714738; Mon, 29 Oct 2018 18:08:34 -0700 (PDT) In-Reply-To: <87lg6gmg9s.fsf@netris.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.210.52 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:19701 Archived-At: --00000000000027b43d057967d373 Content-Type: text/plain; charset="UTF-8" On Tue, Oct 30, 2018 at 1:26 AM Mark H Weaver wrote: > 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. > Well, this could be interpreted in two ways. What I expect is that $$0 always refers to the last entry of the value history, even if it has been extended, such that $$0 will evaluate to new values as new values are pushed onto value history. This is also the effect we get if $$0 expands to (list-ref value-history 0). > > 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. > Maybe this is a Microsoft-style argument, but do we really expect users to use value history in that way? If so, I guess value-history could be stored in a dynamically enlarged vector. > 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). > (This (count) is what I had in mind for $: $ -> (list-ref value-history (- count )) ) > * $$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? > This would then have the problem that $$0 would get a more complex meaning: It would mean "the most recent result at the time of macro expansion" rather than "the most recent result". If efficiency really is a concern, I would expect that vector references would be rather efficient after compilation. Best regards, Mikael --00000000000027b43d057967d373 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue= , Oct 30, 2018 at 1:26 AM Mark H Weaver <mhw@netris.org> wrote:
Mi= kael Djurfeldt <mikael@djurfeldt.com> 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<= br> > history.

A few more suggestions:

If I write (define (foo x) (+ $$0 x)) at the repl, then I expect 'foo&#= 39;
to continue to refer to the same entry in the value history, even after
the value history is later extended.

We= ll, this could be interpreted in two ways. What I expect is that $$0 always= refers to the last entry of the value history, even if it has been extende= d, such that $$0 will evaluate to new values as new values are pushed onto = value history.

This is also the effect we get if $= $0 expands to (list-ref value-history 0).

I'm also a bit concerned about the efficiency implications of expanding=
these variable references into 'list-ref' calls when the history gr= ows
large.=C2=A0 If I write a loop that evaluates $$0 a million times, I'd = prefer
to avoid a million 'list-ref' calls.

Maybe this is a Microsoft-style argument, but do we really expect use= rs to use value history in that way? If so, I guess value-history could be = stored in a dynamically enlarged vector.


To address these concerns, I'd like to suggest a slightly different
approach:

* $0, $1, ... would continue to be ordinary variable bindings in
=C2=A0 (value-history), as they are now.

* The 'count' in 'save-value-history' would be made into a = top-level
=C2=A0 variable in (ice-9 history).

(Th= is (count) is what I had in mind for $<N>: $<N> -> (list-ref= value-history (- count <N>)) )
=C2=A0
* $$0, $$1, $$2, ... would be handled by a lazy-binder, providing a
=C2=A0 syntax transformer that looks at the value of 'count' at mac= ro
=C2=A0 expansion time, and expands into the appropriate variable
=C2=A0 reference $N.

For example, if $5 is the most recent value, $$0 would expand into $5
instead of (list-ref ...).=C2=A0 This would eliminate my concerns over
efficiency.

What do you think?

This would then= have the problem that $$0 would get a more complex meaning: It would mean = "the most recent result at the time of macro expansion" rather th= an "the most recent result".=C2=A0

If ef= ficiency really is a concern, I would expect that vector references would b= e rather efficient after compilation.

Best regards= ,
Mikael
--00000000000027b43d057967d373--