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: Feature request: Expose `ellipsis?' from psyntax.ss Date: Fri, 23 Nov 2018 15:25:18 -0500 Message-ID: <87a7lzpmly.fsf@netris.org> References: <875zwzmq4n.fsf@netris.org> <87pnv6iss7.fsf@netris.org> <87k1leip2i.fsf@netris.org> <124085ab-2a76-4892-e790-d58b07bcb3fc@nieper-wisskirchen.de> <87lg5tj3gn.fsf@netris.org> <874lcgzj9p.fsf@netris.org> <871s7fuml7.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1543004670 10675 195.159.176.226 (23 Nov 2018 20:24:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 23 Nov 2018 20:24:30 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: guile-devel@gnu.org To: Marc =?utf-8?Q?Nieper-Wi=C3=9Fkirchen?= Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Nov 23 21:24:26 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 1gQHzy-0002e3-47 for guile-devel@m.gmane.org; Fri, 23 Nov 2018 21:24:22 +0100 Original-Received: from localhost ([::1]:54193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gQI24-00038H-9J for guile-devel@m.gmane.org; Fri, 23 Nov 2018 15:26:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gQI1g-00038B-NV for guile-devel@gnu.org; Fri, 23 Nov 2018 15:26:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gQI1c-0005L0-1i for guile-devel@gnu.org; Fri, 23 Nov 2018 15:26:08 -0500 Original-Received: from world.peace.net ([64.112.178.59]:55662) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gQI1b-0005JP-Ts for guile-devel@gnu.org; Fri, 23 Nov 2018 15:26:03 -0500 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 1gQI1a-0001cc-0g; Fri, 23 Nov 2018 15:26:02 -0500 In-Reply-To: ("Marc \=\?utf-8\?Q\?Nieper-Wi\=C3\=9Fkirchen\=22's\?\= message of "Wed, 21 Nov 2018 09:40:36 +0100") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] 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:19761 Archived-At: Hi Marc, Marc Nieper-Wi=C3=9Fkirchen writes: > Am Mi., 21. Nov. 2018 um 04:38 Uhr schrieb Mark H Weaver : > > I'm not aware of any language in the R[567]RS that makes it clear > whether '...' should be recognized as an ellipsis if it is bound to a > variable. The Scheme implementations I tried do not seem to agree. > > For example, consider this example: > > (let ((... 'hello)) > (let-syntax ((foo (syntax-rules () > ((foo x ...) > '((x) ...))))) > (foo 1 2))) > > If '...' is recognized as an ellipsis within the 'let', then the result > will be '((1) (2)). Otherwise, the result will be '((1) 2). > > I just tested with Chez Scheme 9.5 as well. It returns the same result as= Chibi, namely '((1) 2).=20 >=20=20 > I found that Racket 7.0, Chicken 4.13.0, and Scheme48 1.9.2 return > '((1) (2)). Chibi-Scheme returns '((1) 2). I see the same results > with this variant: > > (let-syntax ((... (syntax-rules ()))) > (let-syntax ((foo (syntax-rules () > ((foo x ...) > '((x) ...))))) > (foo 1 2))) > > Again, Chez returns '((1) 2). > > If we instead bind '...' as a top-level variable: > > (define-syntax ... (syntax-rules ())) > (let-syntax ((foo (syntax-rules () > ((foo x ...) > '((x) ...))))) > (foo 1 2)) > > Then all four of these Schemes agree that the answer is '((1) (2)), > including Chibi-Scheme. > > Chez Scheme still returns '((1) 2) and thus does not recognize `...' > as the ellipsis. I stand by the analysis in my previous response in this thread, but nonetheless I've since realized that given the current implementation of 'ellipsis?' in psyntax.scm, Guile *should* be returning '((1) 2) in these examples above, and I'm not sure why that's not happening. The reason is that when no ellipsis binding is present, Guile currently uses 'free-identifier=3D?' to compare identifiers with #'(... ...) in psyntax.scm, where '...' has no binding. In the examples above, the ellipsis identifiers are within a lexical environment where '...' is bound, so 'free-identifier=3D?' should be returning #false in these cases. Having said this, given the analysis in my previous response, I'm now wondering whether it's a mistake to use 'free-identifier=3D?' to check for the default ellipsis '...'. Within the lexical scope of 'with-ellipsis', Guile uses 'bound-identifier=3D?' to check for the user-defined ellipsis, but perhaps we should be using it uniformly to check for ellipsis in all cases. What do you think? Also, for the sake of completeness I should explain a remaining detail of Guile's semantics for 'with-ellipsis' bindings. In my previous response, I wrote: > I think it makes more sense to model (with-ellipsis E BODY) as > introducing a new lexical binding with a fixed name. CURRENT-ELLIPSIS > would be a good name if we wanted to make it part of the public API. In > this model, 'E' becomes the _value_ of the binding, instead of the > binding's name. In existing versions of Guile, the special fixed name is equivalent to: (datum->syntax E '#{ $sc-ellipsis }#) Where E is the identifier being bound or checked. In particular, the _marks_ from E are copied to the special fixed name, both when binding a new ellipsis identifier and when checking for ellipsis identifier. In other words, for each set of marks there's a distinct ellipsis binding. WARNING: Note that the name #{ $sc-ellipsis }# is not part of Guile's API, and is subject to change. We reserve the right to change its name, or to make it completely inaccessible in future versions of Guile. For example, we might move the ellipsis bindings out of the substitution and into a separate field in the wrap which maps marks to ellipsis identifiers, with no name involved at all. I welcome input on these questions. Mark