Re: syntax-rules question

Joseph Donaldson <[email protected]> Tue, 3 Jan 2023 22:55:41 +0000 (UTC)
Newsgroups gmane.lisp.scheme.bigloo
Message-ID <[email protected]>
------=_Part_6822469_1924906010.1672786541074
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

 Hello, Manuel,
Happy new year and best wishes to you as well.
Upon further investigation, I have found that my change to hygiene-value is=
 not sound and causes hygiene problems in some situations. Fortunately, I b=
elieve I have found a fix that retains hygiene and expands the CPS style ma=
cros found in SRFI-42 (eager comprehensions). I propose we rename my versio=
n of hygien-value to hygiene-value* and only use it in the definition of ge=
t-syntax-expander. All other occurrences of hygiene-value will use the orig=
inal definition. A pull request with these changes can be found at https://=
github.com/manuel-serrano/bigloo/pull/91. I cannot be 100% certain but have=
 yet to discover any hygiene problems with this change.
Best Regards,Joe Donaldson
=20



    On Tuesday, January 3, 2023 at 07:04:07 AM PST, [email protected]=
 <[email protected]> wrote: =20
=20
 Hi Joe,

Happy new year and best wishes for 2023.

> Hello, Manuel,
> I am porting SRFI-42 (Eager Comprehensions) to Bigloo. In doing this, I r=
an into a couple of problems. The first was that the default implementation=
 assumes that identifiers can start with colons (:) and this is not true fo=
r Bigloo; keywords start or end with a colon. I was able to address this in=
 the manner Alex Shinn did in his gauche implementation of SRFI-42 by renam=
ing. The next problem I ran into was a syntax-rules expansion problem. Due =
to the continuation passing style of the macros being used, symbols were be=
ing multiply prepended with the hygiene-mark (|hygiene.r5rs.mark|) but the =
current definition of hygiene-value only strips off a single instance of th=
e hygiene-mark. I was able to work around this by changing the definition o=
f hygiene-value to strip all occurrences of hygiene-mark not just the first=
. See below. However, I am not sure that this is correct from a hygiene per=
spective or not. Does this definition of hygiene-value call problems.
>=20
>=20
> (define (hygiene-value x)
> =C2=A0=C2=A0 (if (not (symbol? x))
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 x
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (let ((s (symbol->string x)))
> =C2=A0=C2=A0 =C2=A0=C2=A0 (let loop ((s s))
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
(if (substring-at? s hygiene-prefix 0)
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 (loop (substring s hygiene-prefix-len (string-leng=
th s)))
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 (string->symbol s))))))

My guess is that it should be correct but I do not remember how this
code works clearly enough to be a 100% sure. I have tried it, and what I
can say is that at least, this modification does not prevent the tests of
the recette directory to run successfully.

--=20
Manuel
 =20
------=_Part_6822469_1924906010.1672786541074
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"ydpc0891839yahoo-style-wrap" style=
=3D"font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px=
;"><div></div>
        <div dir=3D"ltr" data-setdir=3D"false">Hello, Manuel,</div><div dir=
=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"fa=
lse">Happy new year and best wishes to you as well.</div><div dir=3D"ltr" d=
ata-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">Upon =
further investigation, I have found that my change to hygiene-value is not =
sound and causes hygiene problems in some situations. Fortunately, I believ=
e I have found a fix that retains hygiene and expands the CPS style macros =
found in SRFI-42 (eager comprehensions). I propose we rename my version of =
hygien-value to hygiene-value* and only use it in the definition of get-syn=
tax-expander. All other occurrences of hygiene-value will use the original =
definition. A pull request with these changes can be found at <a href=3D"ht=
tps://github.com/manuel-serrano/bigloo/pull/91" rel=3D"nofollow" target=3D"=
_blank" class=3D"">https://github.com/manuel-serrano/bigloo/pull/91</a>. I =
cannot be 100% certain but have yet to discover any hygiene problems with t=
his change.</div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=
=3D"ltr" data-setdir=3D"false">Best Regards,</div><div dir=3D"ltr" data-set=
dir=3D"false">Joe Donaldson<br> </div><div><br></div><div><br></div><div><b=
r></div><div><br></div>
       =20
        </div><div id=3D"ydp2e962ac1yahoo_quoted_3630714499" class=3D"ydp2e=
962ac1yahoo_quoted">
            <div style=3D"font-family:'Helvetica Neue', Helvetica, Arial, s=
ans-serif;font-size:13px;color:#26282a;">
               =20
                <div>
                    On Tuesday, January 3, 2023 at 07:04:07 AM PST, Manuel.=
[email protected] &lt;[email protected]&gt; wrote:
                </div>
                <div><br></div>
                <div><br></div>
                <div><div dir=3D"ltr">Hi Joe,<br></div><div dir=3D"ltr"><br=
></div><div dir=3D"ltr">Happy new year and best wishes for 2023.<br></div><=
div dir=3D"ltr"><br></div><div dir=3D"ltr">&gt; Hello, Manuel,<br></div><di=
v dir=3D"ltr">&gt; I am porting SRFI-42 (Eager Comprehensions) to Bigloo. I=
n doing this, I ran into a couple of problems. The first was that the defau=
lt implementation assumes that identifiers can start with colons (:) and th=
is is not true for Bigloo; keywords start or end with a colon. I was able t=
o address this in the manner Alex Shinn did in his gauche implementation of=
 SRFI-42 by renaming. The next problem I ran into was a syntax-rules expans=
ion problem. Due to the continuation passing style of the macros being used=
, symbols were being multiply prepended with the hygiene-mark (|hygiene.r5r=
s.mark|) but the current definition of hygiene-value only strips off a sing=
le instance of the hygiene-mark. I was able to work around this by changing=
 the definition of hygiene-value to strip all occurrences of hygiene-mark n=
ot just the first. See below. However, I am not sure that this is correct f=
rom a hygiene perspective or not. Does this definition of hygiene-value cal=
l problems.<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt; =
<br></div><div dir=3D"ltr">&gt; (define (hygiene-value x)<br></div><div dir=
=3D"ltr">&gt; &nbsp;&nbsp; (if (not (symbol? x))<br></div><div dir=3D"ltr">=
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x<br></div><div dir=3D"ltr">&gt; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (let ((s (symbol-&gt;string x)))<br></=
div><div dir=3D"ltr">&gt; &nbsp;&nbsp; &nbsp;&nbsp; (let loop ((s s))<br></=
div><div dir=3D"ltr">&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp; (if (substring-at? s hygiene-prefix 0)<br></div><di=
v dir=3D"ltr">&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (loop (substring s hygiene-prefix-=
len (string-length s)))<br></div><div dir=3D"ltr">&gt; &nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
; (string-&gt;symbol s))))))<br></div><div dir=3D"ltr"><br></div><div dir=
=3D"ltr">My guess is that it should be correct but I do not remember how th=
is<br></div><div dir=3D"ltr">code works clearly enough to be a 100% sure. I=
 have tried it, and what I<br></div><div dir=3D"ltr">can say is that at lea=
st, this modification does not prevent the tests of<br></div><div dir=3D"lt=
r">the recette directory to run successfully.<br></div><div dir=3D"ltr"><br=
></div><div dir=3D"ltr">-- <br></div><div dir=3D"ltr">Manuel<br></div></div=
>
            </div>
        </div></body></html>
------=_Part_6822469_1924906010.1672786541074--