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 19:54:14 -0400 Message-ID: <87pnvsmhq6.fsf@netris.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1540857188 28328 195.159.176.226 (29 Oct 2018 23:53:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 29 Oct 2018 23:53:08 +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 00:53:04 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 1gHHLE-0007GS-2j for guile-devel@m.gmane.org; Tue, 30 Oct 2018 00:53:04 +0100 Original-Received: from localhost ([::1]:49730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHHNK-0003aj-8g for guile-devel@m.gmane.org; Mon, 29 Oct 2018 19:55:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHHNB-0003Yc-DR for guile-devel@gnu.org; Mon, 29 Oct 2018 19:55:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHHN6-0001Qc-Au for guile-devel@gnu.org; Mon, 29 Oct 2018 19:55:05 -0400 Original-Received: from world.peace.net ([64.112.178.59]:33364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHHN6-0001QR-7A for guile-devel@gnu.org; Mon, 29 Oct 2018 19:55:00 -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 1gHHN4-0000cX-Rc; Mon, 29 Oct 2018 19:54:59 -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:19698 Archived-At: Hi Mikael, Mikael Djurfeldt writes: > I'd like to rewrite (ice-9 history) to conform to the full GDB value > history syntax. This is because I find that I miss being able to refer > to "the last value" etc. Yes, I've also missed this! > Currently we have: > > $ the N:th value from the start > > The extension would add bindings for: > > $$ the N:th value from the end > > $ the last value (= $$0) > > $$ the value just prior to the last value (= $$1) > > Implementation: > > Currently, every step in the REPL defines a $ in the module > (value-history) the interface of which is appended to the list of used > interfaces for the (current-module). > > The new implementation would just add a new result value to a list, > not doing any definition. > > 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. > > Please evaluate this suggestion and give comments or an OK. This strategy sounds good to me. I'd also like to hear what Andy and Ludovic think. However, there's a complication with using '$' in this way. '$' is already widely used as part of the syntax for (ice-9 match), to specify patterns that match record objects. More precisely, it is a literal identifier recognized by 'match' and related macros, in the same sense that 'else' and '=>' are literal identifiers recognized by the 'cond' macro. R5RS section 4.3.2 (Pattern language) specifies how these literal identifiers are to be compared with identifiers found in each macro use: Identifiers that appear in are interpreted as literal identifiers to be matched against corresponding subforms of the input. A subform in the input matches a literal identifier if and only if it is an identifier and either both its occurrence in the macro expression and its occurrence in the macro definition have the same lexical binding, or the two identifiers are equal and both have no lexical binding. The implication is that these literal identifiers such as 'else', '=>' and '$' lose their special meaning in any environment where they are bound, unless the same binding is visible in the corresponding macro definition environment. R6RS and R7RS also specify this behavior. For example: --8<---------------cut here---------------start------------->8--- mhw@jojen ~$ guile GNU Guile 2.2.3 Copyright (C) 1995-2017 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> ,use (ice-9 match) scheme@(guile-user)> ,use (srfi srfi-9) scheme@(guile-user)> (define-record-type (make-foo a b) foo? (a foo-a) (b foo-b)) scheme@(guile-user)> (match (make-foo 1 2) (($ a b) (+ a b))) $1 = 3 scheme@(guile-user)> (define $ 'blah) scheme@(guile-user)> (match (make-foo 1 2) (($ a b) (+ a b))) :6:0: Throw to key `match-error' with args `("match" "no matching pattern" #< a: 1 b: 2>)'. Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile-user) [1]> --8<---------------cut here---------------end--------------->8--- To avoid colliding with the popular 'match' syntax, how about making '$$' the last value ($$0), and omitting the alias for '$$1'? What do you think? Regards, Mark