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-note check exemptedThe NO_RELEASE_NOTES label exempts this 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 |
|
@copilot resolve the merge conflicts in this pull request |
1 similar comment
|
@copilot resolve the merge conflicts in this pull request |
|
No warning against using printf with $? |
|
@copilot resolve the merge conflicts in this pull request |
|
I don't wan't to introduce a lot of warnings for existing codebases - at least not without a centralized analyzer+fixer story. (There are environments where people maintain working codebases without motivation to touch the code much, but still we want them to update their SDK and not receive a flood of new warnings for code that was OK) |
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