syntax-rules question

Joseph Donaldson <[email protected]> Mon, 2 Jan 2023 18:18:47 +0000 (UTC)
Newsgroups gmane.lisp.scheme.bigloo
Message-ID <[email protected]>
------=_Part_6502619_746858493.1672683527349
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hello, Manuel,
I am porting SRFI-42 (Eager Comprehensions) to Bigloo. In doing this, I ran=
 into a couple of problems. The first was that the default implementation a=
ssumes that identifiers can start with colons (:) and this is not true for =
Bigloo; keywords start or end with a colon. I was able to address this in t=
he manner Alex Shinn did in his gauche implementation of SRFI-42 by renamin=
g. 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 bein=
g multiply prepended with the hygiene-mark (|hygiene.r5rs.mark|) but the cu=
rrent definition of hygiene-value only strips off a single 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 not just the first. =
See below. However, I am not sure that this is correct from a hygiene persp=
ective or not. Does this definition of hygiene-value call problems.


(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 (i=
f (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-length =
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))))))
Thank You,Joseph Donaldson
=20
------=_Part_6502619_746858493.1672683527349
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"yahoo-style-wrap" style=3D"font-fami=
ly:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir=
=3D"ltr" data-setdir=3D"false">Hello, Manuel,</div><div dir=3D"ltr" data-se=
tdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">I am portin=
g SRFI-42 (Eager Comprehensions) to Bigloo. In doing this, I ran into a cou=
ple of problems. The first was that the default implementation assumes that=
 identifiers can start with colons (:) and this is not true for Bigloo; key=
words start or end with a colon. I was able to address this in the manner A=
lex Shinn did in his gauche implementation of SRFI-42 by renaming. The next=
 problem I ran into was a syntax-rules expansion problem. Due to the contin=
uation passing style of the macros being used, symbols were being multiply =
prepended with the hygiene-mark (<span>|hygiene.r5rs.mark|) but the current=
 definition of hygiene-value only strips off a single instance of the hygie=
ne-mark. I was able to work around this by changing the definition of hygie=
ne-value to strip all occurrences of hygiene-mark not just the first. See b=
elow. However, I am not sure that this is correct from a hygiene perspectiv=
e or not. Does this definition of hygiene-value call problems.<br></span></=
div><div dir=3D"ltr" data-setdir=3D"false"><span><br></span></div><div dir=
=3D"ltr" data-setdir=3D"false"><span><br></span></div><div dir=3D"ltr" data=
-setdir=3D"false"><div>(define (hygiene-value x)<br>&nbsp;&nbsp; (if (not (=
symbol? x))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x<br>&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp; (let ((s (symbol-&gt;string x)))<br>&nbsp;&nbsp; &nbsp;&=
nbsp; (let loop ((s s))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp; (if (substring-at? s hygiene-prefix 0)<br>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; (loop (substring s hygiene-prefix-len (string-length s)))<br>=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp; (string-&gt;symbol s))))))</div><div><br></div><div d=
ir=3D"ltr" data-setdir=3D"false">Thank You,</div><div dir=3D"ltr" data-setd=
ir=3D"false">Joseph Donaldson<br></div> </div></div></body></html>
------=_Part_6502619_746858493.1672683527349--