Cleanup: use printn/print instead of printfn/printf for interpolated strings - #20542
charlesroddie wants to merge 5 commits into
Conversation
…vailable Replace printfn $"..." with printn $"..." in FSharp.Core doc examples, commented-out code, FSharp.Core.UnitTests and SDK-run scripts. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
❗ Release notes requiredYou can open this PR in browser to add release notes: open in github.dev Caution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository: `* . (PR #XXXXX)`
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.
|
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
🔍 Tooling Safety Check — Affects-Build-Infra, Affects-Test-Tooling
|
|
Should also implement a warning against using printf with |
Prior to
print(n), we could not print interpolated strings directly using FSharp syntax, and had to go through a formatted string path (printf(n) $"..."). This PR starts to useprint(n)for these cases.The advantages are simpler types and reduced cognitive complexity, improved performance, and being able to benefit from the new changes in interpolated strings (fsharp/fslang-suggestions#1468 (comment)).
Moreover, the less
printfthere is in public code, including the FSharp repo, the less AIs will use it.Details
This PR replaces
printfn $"..."withprintn $"..."andprintf $"..."withprint $"..."(FS-1125) where the referenced FSharp.Core has them, and removes the one redundantsprintfbefore an interpolated string.Changed
set,async,eventmodule,observable,array2,array3)coroutines.fsxeng/tests/TestSplit.fsx(runs on the SDK's FSharp.Core)TheBigFileOfDebugStepping.fsx(manual walkthrough compiled with the repo's fsc)RemoveUnnecessaryParenthesesTests(syntax-only inputs; continuation lines align with the function name, so layout is unchanged)TransparentCompiler.fs:sprintf $"F%03d{i}"→$"F%03d{i}"Not changed
FSharp.Compiler.Service.slnx(includingtests/scripts/scriptlib.fsx): withFSHARPCORE_USE_PACKAGE=truethey build against the shipped FSharp.Core 10.0.101, which lacksprint/printn.printfitself (TypedInterpolatedStringsTests,StringFormatAndInterpolation) stay regardless.sprintf $uses: they testsprintf $itself (printf-interpolated/test.fsx,StringInterpolation.fs,EditorTests.fs) or describe that code path (printf.fs)..githubdiagnostics server,docs/fcs: FSharp.Core 10 or own tooling.printf.fsi: those examples documentprintf/printfn.The remainder can follow once the shipped FSharp.Core pin moves to 11.
🤖 Generated with Claude Code