From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.devel Subject: Re: Precedence for reader extensions Date: Tue, 19 Feb 2013 17:42:02 +0100 Message-ID: References: <87mwv1nqns.fsf@tines.lan> <87a9r0gvld.fsf@tines.lan> Reply-To: mikael@djurfeldt.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=047d7b66f1c7621d2d04d616852c X-Trace: ger.gmane.org 1361292474 29311 80.91.229.3 (19 Feb 2013 16:47:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 19 Feb 2013 16:47:54 +0000 (UTC) Cc: guile-devel To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Feb 19 17:48:17 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U7qMa-0000BE-QV for guile-devel@m.gmane.org; Tue, 19 Feb 2013 17:48:17 +0100 Original-Received: from localhost ([::1]:58876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7qMG-0000h2-Nh for guile-devel@m.gmane.org; Tue, 19 Feb 2013 11:47:56 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:51789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7qM2-0000gA-G8 for guile-devel@gnu.org; Tue, 19 Feb 2013 11:47:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U7qLp-00065L-DN for guile-devel@gnu.org; Tue, 19 Feb 2013 11:47:42 -0500 Original-Received: from mail-ee0-f44.google.com ([74.125.83.44]:59484) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7qLo-00064T-Px for guile-devel@gnu.org; Tue, 19 Feb 2013 11:47:29 -0500 Original-Received: by mail-ee0-f44.google.com with SMTP id l10so3567850eei.17 for ; Tue, 19 Feb 2013 08:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:reply-to:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=RJoBQHJ4DeRN1Y/DULGRLfhMohoISIZaMAvYjnC2Npk=; b=0UIh+vbkXWott+xnSUc4M5JaE/dTZj0Yge9r8e07XOwedcV/RsB9SFxVjXVeywPmEn m2NYD4075s3OEujLjeeiv4CiUtSXgFiafJk/gkaM4NMCegTJWPjvW69YcrP16C9TMCaF fXZLjuyoVJ5fwOhUusLwbkkNfcJx+7udfWavT+oFjBmG4tc24AcqKv5QAN+fCAgT/v9M OGmYiYF47yfgqaWg1oQlc9S+yNA6qBLFMXx43dUizKFDe950a+tjRoBMyLqSvxaruqlO UUzfQMMghdTR8U9oXTEy6XncqE0k2ie50HGjMBnHTRSLJqmZSZI6Be5Wex3TDoCRNys0 g/tg== X-Received: by 10.14.4.69 with SMTP id 45mr59148287eei.0.1361292122266; Tue, 19 Feb 2013 08:42:02 -0800 (PST) Original-Received: by 10.14.225.2 with HTTP; Tue, 19 Feb 2013 08:42:02 -0800 (PST) In-Reply-To: <87a9r0gvld.fsf@tines.lan> X-Google-Sender-Auth: 5awS0OOyQEklApQT4as_hNwgrAk X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 74.125.83.44 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15782 Archived-At: --047d7b66f1c7621d2d04d616852c Content-Type: text/plain; charset=ISO-8859-1 On Tue, Feb 19, 2013 at 4:41 PM, Mark H Weaver wrote: > Mikael Djurfeldt writes: >> On Tue, Feb 19, 2013 at 12:33 AM, Mark H Weaver wrote: >>> Mikael Djurfeldt writes: >>>> I propose to simplify this to only two levels: >>>> >>>> 1. %read-hash-procedures >>>> 2. predefined syntax >> >> It turns out that the change I propose above was already implemented >> in read.c. The effect just wasn't visible due to a bug in flush_ws >> which caused all #! to be erroneously removed if they exist as the >> outermost expression. > > I'm not sure that I consider this a bug. In this reply I've attached a file mit-reader-scm which installs a hash-read-procedure for #\!. What I wanted to say above is that scm_read_sharp (in HEAD) is implemented with the priorities I list above while flush_ws is implemented with other priorities. Here's a demo of the consequences of this bug: scheme@(guile-user)> (load "mit-reader.scm") scheme@(guile-user)> (quote #!optional) ... !# hi) $1 = hi scheme@(guile-user)> '#!optional $2 = #:optional > [...] > I'm uncomfortable with globally overriding standard read syntax. In a > large scheme system such as Guile, there are many modules that use > 'read' and expect it to act in accordance with standard lexical > conventions. Well, in the mit-scheme compatibility module, my intention was to use dynamic-wind to modify #!-syntax while loading mit-scheme-specific files. Note that %read-hash-procedures is a fluid, so this will be absolutely local and won't leak out in any way to the rest of the system. > The problem with this approach is that it does not compose. Let's now patch guile according to the diff I sent... there! scheme@(guile-user)> (load "mit-reader.scm") scheme@(guile-user)> (quote #!optional) $1 = #:optional scheme@(guile-user)> '#!optional $2 = #:optional scheme@(guile-user)> (quote #!hi!# #!optional) $3 = #:optional My take on this is: * The %read-hash-procedures API is not pretty * The suggested change doesn't make things prettier * The suggested change *does* make things conceptually simpler and more flexible (= you can always override hash syntax if you want; compared to the current: you can override #| but not other hash syntax) * The suggested change fixes a bug * The suggested change does compose and different syntax can be confined to a module by using dynamic-wind Best regards, Mikael --047d7b66f1c7621d2d04d616852c Content-Type: application/octet-stream; name="mit-reader.scm" Content-Disposition: attachment; filename="mit-reader.scm" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hdd9mk7m0 KGRlZmluZSAoJXJlYWQtbWl0LWNvbnN0YW50cyBjIHBvcnQpCiAgKGRlZmluZSAodHJ5LXJlYWQg c3RyaW5nKQogICAgKGxldCAoKGxlbmd0aCAoc3RyaW5nLWxlbmd0aCBzdHJpbmcpKSkKICAgICAg KGxldCBsb29wICgoaSAwKSkKCShjb25kICgoPSBpIGxlbmd0aCkgKHN5bWJvbC0+a2V5d29yZCAo c3RyaW5nLT5zeW1ib2wgc3RyaW5nKSkpCgkgICAgICAoKG5vdCAoY2hhcj0/IChwZWVrLWNoYXIg cG9ydCkgKHN0cmluZy1yZWYgc3RyaW5nIGkpKSkKCSAgICAgICAodW5yZWFkLXN0cmluZyAoc3Vi c3RyaW5nIHN0cmluZyAwIGkpIHBvcnQpCgkgICAgICAgKnVuc3BlY2lmaWVkKikKCSAgICAgIChl bHNlIChyZWFkLWNoYXIgcG9ydCkKCQkgICAgKGxvb3AgKCsgMSBpKSkpKSkpKQogIChjYXNlIChw ZWVrLWNoYXIgcG9ydCkKICAgICgoI1xvKSAodHJ5LXJlYWQgIm9wdGlvbmFsIikpCiAgICAoKCNc cikgKHRyeS1yZWFkICJyZXN0IikpKSkKCihkZWZpbmUgKGluc3RhbGwtaGFzaC1wcm9jZWR1cmUh IGMgcHJvYykKICAobGV0ICgoYWxzIChmbHVpZC1yZWYgJXJlYWQtaGFzaC1wcm9jZWR1cmVzICkp KQogICAgKGNvbmQgKChhc3N2IGMgYWxzKQoJICAgPT4gKGxhbWJkYSAocCkKCQkoc2V0LWNkciEg cCBwcm9jKSkpCgkgIChlbHNlCgkgICAoZmx1aWQtc2V0ISAlcmVhZC1oYXNoLXByb2NlZHVyZXMK CQkgICAgICAgKGNvbnMgKGNvbnMgYyBwcm9jKSBhbHMpKSkpKSkKCihpbnN0YWxsLWhhc2gtcHJv Y2VkdXJlISAjXCEgJXJlYWQtbWl0LWNvbnN0YW50cykK --047d7b66f1c7621d2d04d616852c--