Conversation
" New racket-tstring package providing template strings with interpolation, parsing, rendering to HTML/SQL, and compile-time source transformation. Includes comprehensive tests for all modules. Modified: - pkgs/racket-tstring/info.rkt - pkgs/racket-tstring/lang/reader.rkt - pkgs/racket-tstring/main.rkt - pkgs/racket-tstring/private/expand.rkt - pkgs/racket-tstring/private/parse.rkt - pkgs/racket-tstring/private/render.rkt - pkgs/racket-tstring/private/source-transform.rkt - pkgs/racket-tstring/private/template.rkt - pkgs/racket-tstring/tests/expand-test.rkt - pkgs/racket-tstring/tests/parse-test.rkt - pkgs/racket-tstring/tests/reader-basic.rkt - pkgs/racket-tstring/tests/reader-error-test.rkt - pkgs/racket-tstring/tests/reader-nesting.rkt - pkgs/racket-tstring/tests/reader-test.rkt - pkgs/racket-tstring/tests/render-test.rkt ")
" Add the tstring collection as a short `#lang reader` wrapper around racket-tstring, providing f\"...\" and t\"...\" template string syntaxes with tests covering rendering, template values, and nesting. Modified: - Makefile - pkgs/tstring/info.rkt - pkgs/tstring/lang/reader.rkt - pkgs/tstring/main.rkt - pkgs/tstring/tests/require-test.rkt - pkgs/tstring/tests/wrapper-racket-base.rkt - pkgs/tstring/tests/wrapper-test.rkt ")
" Replace interpolation-kind/interpolation-source with interpolation-format-spec/interpolation-conversion, supporting format specifiers and conversion flags in template strings. Add template-parts to interleave strings and interpolations. Add racket/interactive/tstring.rkt for REPL template string support. Modified: - pkgs/racket-tstring/main.rkt - pkgs/racket-tstring/private/expand.rkt - pkgs/racket-tstring/private/render.rkt - pkgs/racket-tstring/private/template.rkt - pkgs/racket-tstring/tests/expand-test.rkt - pkgs/racket-tstring/tests/reader-test.rkt - pkgs/racket-tstring/tests/render-test.rkt - pkgs/tstring/tests/require-test.rkt - pkgs/tstring/tests/wrapper-test.rkt - racket/collects/racket/interactive/tstring.rkt - racket/src/pkgs-config.rkt ")
" Implement format-fstring-value to support Python-style format specifiers including alignment (<, >, ^, =), sign handling (+, -, space), zero padding, width, precision, and type specifiers (d, b, o, x, X, f, F, e, E, g, G, %). Wire format spec and conversion through expand-time to runtime interception. Modified: - pkgs/racket-tstring/private/expand.rkt - pkgs/racket-tstring/private/render.rkt - pkgs/racket-tstring/tests/expand-test.rkt ")
|
I think there’s no reason these packages need to be in this repo. (We already have |
From the implementation side, bare From the feature side, this follows Python’s established f-string model and its newer t-string/template-string direction (PEP 498, PEP 750), and explores whether first-tier Racket support can improve everyday REPL ergonomics and structured-string workflows. |
|
It's true that it needs reader-level integration, but Racket's reader is extensible and #lang notation with meta-languages like |
|
This pull request has been mentioned on Racket Discourse. There might be relevant details there: https://racket.discourse.group/t/when-racket-meets-python-style-strings/4295/1 |
Summary
racket-tstringpackage that implements structured template strings, including parsing, expansion, rendering, and reader support.tstringpackage as the public wrapper/alias and register both packages in the build configuration.racket/interactive/tstringsupport for REPL use.Tests
raco make pkgs/racket-tstring/tests/*.rkt pkgs/tstring/tests/*.rktraco test pkgs/racket-tstring/tests pkgs/tstring/tests(95 tests passed)