Add generic print and println functions to FSharp.Core #19265
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This is another take on RFC FS-1125, following up on the closed #13597. I guess that's mostly an attempt to see if anyone's interested in driving the old proposal to the finish line. For me those would definitely be handy functions to have, but obviously they are not something very important.
The key difference from the original PR is that
printandprintlnare generic ('T -> unit) rather thanstring -> unit, addressing the feedback from @dsyme that a generic print function would be a better use of the "good name":Both functions use the existing
stringoperator for conversion, which already:IFormattabletypes (consistent withprintfn,sprintf, etc.).ToString()for other types (F# types likeOption,List, etc. have good.ToString()overrides)Changes
printandprintlnsignatures with XML docs tofslib-extra-pervasives.fsifslib-extra-pervasives.fsPrintTests.fs) covering: string, int, float, bool, Option, None, list, newline behavior, and concatenationOpen questions
eprintf(n)andfprintf(n)? Do they generic counterparts as well?