guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Syntax locations are ambiguous: can we track source 'offset' and 'le


From: Vivien Kraus
Subject: Re: Syntax locations are ambiguous: can we track source 'offset' and 'length'?
Date: Wed, 04 Aug 2021 14:25:45 +0200
User-agent: mu4e 1.4.15; emacs 27.2

Ludovic Courtès 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, ‘read-syntax’ appeared in 3.0.7, so it’s 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=core-updates&id=8419221620191d2988c22f6e7811d9ce1e0837bf#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’m happy to see this pretty-print-with-comments function. I want guile
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’m sure wisp people
would like it. I hope to see "guix style" one day :)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]