You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Investigate codegen-based "%A" format string #16663
To make this more manageable, the feature can be scoped to replacing the sprintfs that currently appear inside generated ToString() methods on DUs and records, when the user has not enabled --reflectionfree. This can be done relatively easily if you give up on carriage returns and spaces. For type DU = | A of B * C just return match du with | DU.A(b, c) -> $A({b}, {c}) and for type Record = { A: U; B: V } just return ${ A = {x.A}; B = {x.B} }.
Why?
Suppose the following things are done, which are high impact and lowish difficulty and so likely to happen before a large feature like this.
To make this more manageable, the feature can be scoped to replacing the sprintfs that currently appear inside generated ToString() methods on DUs and records, when the user has not enabled --reflectionfree. This can be done relatively easily if you give up on carriage returns and spaces. For type DU = | A of B * C just return match du with | DU.A(b, c) -> $A({b}, {c}) and for type Record = { A: U; B: V } just return ${ A = {x.A}; B = {x.B} }.
Why?
Suppose the following things are done, which are high impact and lowish difficulty and so likely to happen before a large feature like this.
Then there is no reason to use printf etc. directly in user code.
All these are orthogonal to the current issue, we have not been planned any of those for .NET 9 and randomly picking those up will just jeopardise what we want to deliver.
This particular issue is about universal approach of how do we want to compile %A specifier, and do it via code generation instead of reflecting into custom objects.
Activity
charlesroddie commentedon Mar 7, 2024
To make this more manageable, the feature can be scoped to replacing the
sprintfs that currently appear inside generatedToString()methods on DUs and records, when the user has not enabled--reflectionfree. This can be done relatively easily if you give up on carriage returns and spaces. Fortype DU = | A of B * Cjust returnmatch du with | DU.A(b, c) -> $A({b}, {c})and fortype Record = { A: U; B: V }just return${ A = {x.A}; B = {x.B} }.Why?
Suppose the following things are done, which are high impact and lowish difficulty and so likely to happen before a large feature like this.
DefaultInterpolatedStringHandlerfsharp/fslang-suggestions#1108) - which is a much smaller task (not necessarily the full suggestion but the collector part).printfetc. with whatever level of trim-annotation it needs. That will ensure it stays out of user code in the relevant scenarios.printfunction (print and printn alongside printf and printfn fsharp/fslang-suggestions#1092) so those people usingprintf ${...}can delete thef.Then there is no reason to use
printfetc. directly in user code.vzarytovskii commentedon Mar 8, 2024
All these are orthogonal to the current issue, we have not been planned any of those for .NET 9 and randomly picking those up will just jeopardise what we want to deliver.
This particular issue is about universal approach of how do we want to compile %A specifier, and do it via code generation instead of reflecting into custom objects.