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 01:55:05 +0100 Message-ID: References: <87pnvsmhq6.fsf@netris.org> Reply-To: mikael@djurfeldt.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000b8ba63057967a352" X-Trace: blaine.gmane.org 1540860835 28854 195.159.176.226 (30 Oct 2018 00:53:55 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2018 00:53:55 +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 01:53:51 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 1gHII3-0007Qc-5C for guile-devel@m.gmane.org; Tue, 30 Oct 2018 01:53:51 +0100 Original-Received: from localhost ([::1]:49908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHIK9-00048a-MS for guile-devel@m.gmane.org; Mon, 29 Oct 2018 20:56:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHIJr-00048I-Ph for guile-devel@gnu.org; Mon, 29 Oct 2018 20:55:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHIJn-000141-2P for guile-devel@gnu.org; Mon, 29 Oct 2018 20:55:43 -0400 Original-Received: from mail-oi1-f179.google.com ([209.85.167.179]:38819) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHIJg-0000zH-JC for guile-devel@gnu.org; Mon, 29 Oct 2018 20:55:34 -0400 Original-Received: by mail-oi1-f179.google.com with SMTP id v83-v6so2950023oia.5 for ; Mon, 29 Oct 2018 17:55:20 -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=UGW7wIbjNzZum5SG4Ia1I9jKFGeZ5s5GgX0AAWn/ioM=; b=Gucr4asWB2vSrLkt6GvtxYUFVvNccqi6jX/Ru2K17O88dHqWXT3ARyiUtUD0kuGbIQ l9BabbeM0jGK+eIRCPikKcKDEZjIBi9SqfHRjGHUq4Tj34oASkcTEzET5JcqckZd71x7 f+UVDi5xkILY4XRhZhcwpAuNtgCorCXN+7RGxYGzSWg8jNic3/QHx7+zWo8dJANqJd44 T3QRNRXYFOiV7Xhg8EzhapNbcsPMipIKYNFF3NEFRgnQYeIGdWDsf+iz0BpbiGLXjW0t MytbXiPL81QPaJshJKbMLOZWpYiA60rc3BoOgxC5WXuMHCsObtVOckJ2iNeG4+Pn1iHU Qrig== X-Gm-Message-State: AGRZ1gJ3yo/uLIGP2Ng/uZ7c6U7c1e0eQrSS5gor2cqKAIFNZDeRyn/A Abp+tWLMX7yzLHkccYWlplLng5XmR5r4HJkyvD0= X-Google-Smtp-Source: AJdET5fBnJJ/uBQcrpDPfbtMkued/BkZoI5JFhQKM4LSfBVsXlF0pxXKdJtpuX3MRktZ9cfzlzbwkHnIhOjtvf4bolE= X-Received: by 2002:aca:b655:: with SMTP id g82-v6mr9238052oif.195.1540860918936; Mon, 29 Oct 2018 17:55:18 -0700 (PDT) In-Reply-To: <87pnvsmhq6.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.167.179 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:19700 Archived-At: --000000000000b8ba63057967a352 Content-Type: text/plain; charset="UTF-8" On Tue, Oct 30, 2018 at 12:55 AM Mark H Weaver wrote: > 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. Yes, I actually looked at this, but thought that $ would be interpreted as a literal inside the match expression, but was probably wrong according to what you write below: > 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--- > Incidentally, this does *not* throw an error in master (unless I made some mistake in this late hour), which then is a bug! > > 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? > Not sure. This might be confusing for GDB users... Let's think about it. --000000000000b8ba63057967a352 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Oct 30, 2018 at 12:55 AM Mark H Weaver <mhw@netris.org> wrote:
However, there's a complicat= ion with using '$' in this way.=C2=A0 '$' is
already widely used as part of the syntax for (ice-9 match), to specify
patterns that match record objects.

Yes, I = actually looked at this, but thought that $ would be interpreted as a liter= al inside the match expression, but was probably wrong according to what yo= u write below:
=C2=A0
=C2= =A0 More precisely, it is a literal
identifier recognized by 'match' and related macros, in the same se= nse
that 'else' and '=3D>' are literal identifiers recognize= d 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:
=C2=A0 =C2=A0 =C2=A0Identifiers that appear in <literals> are interpr= eted as literal
=C2=A0 =C2=A0 =C2=A0identifiers to be matched against corresponding subform= s of the
=C2=A0 =C2=A0 =C2=A0input.=C2=A0 A subform in the input matches a literal i= dentifier if and
=C2=A0 =C2=A0 =C2=A0only if it is an identifier and either both its occurre= nce in the
=C2=A0 =C2=A0 =C2=A0macro expression and its occurrence in the macro defini= tion have
=C2=A0 =C2=A0 =C2=A0the same lexical binding, or the two identifiers are eq= ual and both
=C2=A0 =C2=A0 =C2=A0have no lexical binding.

The implication is that these literal identifiers such as 'else', &= #39;=3D>'
and '$' lose their special meaning in any environment where they ar= e
bound, unless the same binding is visible in the corresponding macro
definition environment.=C2=A0 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 <foo> (make-foo a b) foo?= (a foo-a) (b foo-b))
scheme@(guile-user)> (match (make-foo 1 2) (($ <foo> a b) (+ a b))= )
$1 =3D 3
scheme@(guile-user)> (define $ 'blah)
scheme@(guile-user)> (match (make-foo 1 2) (($ <foo> a b) (+ a b))= )
<unnamed port>:6:0: Throw to key `match-error' with args `("= match" "no matching pattern" #<<foo> a: 1 b: 2>)= '.

Entering a new prompt.=C2=A0 Type `,bt' for a backtrace or `,q' to = continue.
scheme@(guile-user) [1]>
--8<---------------cut here---------------end--------------->8---
=

Incidentally, this does *not* throw an err= or in master (unless I made some mistake in this late hour), which then is = a bug!
=C2=A0

To avoid colliding with the popular 'match' syntax, how about makin= g
'$$' the last value ($$0), and omitting the alias for '$$1'= ?

What do you think?

Not sure. This might= be confusing for GDB users... Let's think about it.
--000000000000b8ba63057967a352--