chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] string interpolation


From: Phil Hofer
Subject: [Chicken-users] string interpolation
Date: Mon, 25 Mar 2019 21:30:09 +0000

Hi all,

I'm looking to perform string interpolation identically to
the #<# multi-line reader macro, but for single-line strings.
The string-utils package has set-sharp-string-interpolation-syntax
and string-interpolate, which do almost exactly what I want, but
the default interpolation only uses (interaction-environment),
which keeps a function like this from working:

(define (print-with-foo x)
   (display #"foo #{x}"))

Conversely, the following works, but doesn't scan as neatly to my eyes:

(define (print-with-foo x)
   (display #<#EOF
foo #{x}
EOF
   ))

I looked at setting the ENV parameter of string-interpolate,
but the 'environments' module has disappeared from CHICKEN 5,
so I can't even clumsily construct a string interpolation environment.

As a last resort, I could write my own reader macro, but I'd like
to explore any existing solutions before heading down that route.
(If someone on this mailing list is a read-syntax wizard and has a
pithy solution in mind, share it!)

Advice greatly appreciated.

Cheers,
Phil



reply via email to

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