From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vivien Kraus via General Guile related discussions Newsgroups: gmane.lisp.guile.user Subject: Re: Syntax locations are ambiguous: can we track source 'offset' and 'length'? Date: Wed, 04 Aug 2021 14:25:45 +0200 Message-ID: <871r799z1y.fsf@planete-kraus.eu> References: <771a6e88782e288143be269b14751b761523e4c1.camel@planete-kraus.eu> <87v94lpg7s.fsf@gnu.org> Reply-To: Vivien Kraus Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13795"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.15; emacs 27.2 Cc: guile-user@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Aug 04 14:26:28 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBFyc-0003Q1-Oc for guile-user@m.gmane-mx.org; Wed, 04 Aug 2021 14:26:26 +0200 Original-Received: from localhost ([::1]:53956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBFyb-0001ta-Al for guile-user@m.gmane-mx.org; Wed, 04 Aug 2021 08:26:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBFyK-0001t8-5j for guile-user@gnu.org; Wed, 04 Aug 2021 08:26:08 -0400 Original-Received: from planete-kraus.eu ([2a00:5881:4008:2810::309]:49256) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1mBFyH-0005pJ-RO; Wed, 04 Aug 2021 08:26:07 -0400 Original-Received: from planete-kraus.eu (localhost.lan [127.0.0.1]) by planete-kraus.eu (OpenSMTPD) with ESMTP id 7363a86f; Wed, 4 Aug 2021 12:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=planete-kraus.eu; h= references:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type:content-transfer-encoding; s=*; bh=CH ZP8LUfy4VWCwzTSbzQitInp8w=; b=Vi1814BMJ7JOX7qrJv+q8RMZTynykUjQIl YIothz7XfMQK3/VicEBdjZTYJA25YD1S8O/Q1LGYJ8nZ6eHM+i5knPquUdJSjM7t Rf6ABlfrQxu30vGi75Axw4l9+lz8ynjTzlY4+q/+P9i0JledsVem38fS6VoFOtaK eFkltvKC4= Original-Received: by planete-kraus.eu (OpenSMTPD) with ESMTPSA id f830c037 (TLSv1.3:AEAD-CHACHA20-POLY1305-SHA256:256:NO); Wed, 4 Aug 2021 12:25:50 +0000 (UTC) In-reply-to: <87v94lpg7s.fsf@gnu.org> Received-SPF: pass client-ip=2a00:5881:4008:2810::309; envelope-from=vivien@planete-kraus.eu; helo=planete-kraus.eu X-Spam_score_int: 2 X-Spam_score: 0.2 X-Spam_bar: / X-Spam_report: (0.2 / 5.0 requ) DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17670 Archived-At: Ludovic Court=C3=A8s writes: >> I am trying to use the guile reader to read scheme comments, in >> addition to the syntax elements. I know with syntax-source where a >> syntax object starts, and I can know where it ends by using a spying >> soft port and re-reading it. However, the #\return ambiguity makes all >> my efforts pointless. > > As you know, =E2=80=98read-syntax=E2=80=99 appeared in 3.0.7, so it=E2=80= =99s brand new and we > could certainly extend (ice-9 read) with more features, including > reading comments. I did not know that, to be honest. > In the meantime, I needed the ability to read comments in Guix, > including with Guile < 3.0.7, so I hacked up this thing: > > https://git.savannah.gnu.org/cgit/guix.git/tree/guix/scripts/style.scm?= h=3Dcore-updates&id=3D8419221620191d2988c22f6e7811d9ce1e0837bf#n50 > > It can read and write while preserving comments. I was tempted not to use the guile reader and go and implement a new reader like you did, but I was too afraid to miss one important thing in the syntax. I=E2=80=99m happy to see this pretty-print-with-comments function. I want g= uile to have a tool that can automatically reformat scheme code, to avoid indentation problems with code reviews and pointless discussions about style. We could even tweak text editors to convert between different styles for viewing the source and for git commits. I=E2=80=99m sure wisp pe= ople would like it. I hope to see "guix style" one day :)