Uh oh!
There was an error while loading. Please reload this page.
[WIP] RFC FS-1001 - String Interpolation - #921
Conversation
c58764b to
15f39cdCompareashic
commented
Feb 1, 2016
Would it be preferable to use interpolation notation similar to other languages? Common things are |
forki
commented
Feb 1, 2016
forki
commented
Feb 1, 2016
A swift sample: |
isaacabraham
commented
Feb 1, 2016
I'm split on the |
isaacabraham
commented
Feb 1, 2016
Yes sure. Frankly it's something that's easy to change anyway. |
There was a problem hiding this comment.
I think these test should be in Compiler unit tests.
FSharp.Core shouldn't know about string interpolation.
ec413d0 to
384faddCompareforki
commented
Feb 2, 2016
just noticed the following last line crashes at runtime with seems we can't format ints. |
forki
commented
Feb 2, 2016
OK "fixed" that NRE exception by making it the same error class like |
forki
commented
Feb 2, 2016
@dsyme, @v2m@7sharp9: I assume the issue is at https://github.com/Microsoft/visualfsharp/pull/921/files#diff-5b9ab9dd9d7133aaf23add1048742031R6376 correct? what can we do? |
7sharp9
commented
Feb 2, 2016
Erm ... dunno, I not looked at the WIP on this lately :-) |
KevinRansom
commented
Feb 3, 2016
I think a spec for this would be preferable to a prototype. It was possible to discus the general approach that was taken for C# before a line of code was written. At the very least decide if we want interpolation in string.Format, printf or both. Should we mimic the C# syntax and format specs, or use the F# syntax ... or both, give some examples of what strings using interpolation look like to illustrate arguments for and against each spec requirement. Let's discuss the language needs for the feature before we pile in and write a ton of code. This seems like a pretty scary feature to "just evolve and debate" Kevin |
forki
commented
Feb 3, 2016
As already written above: language design is at https://github.com/fsharp/FSharpLangDesign/blob/master/FSharp-4.1-Proposals/StringInterpolation.md I just rebase an existing explorative implementation on the latest master and added couple of tests to see how far it went. |
isaacabraham
commented
Feb 3, 2016
I don't think Steffen expects this to go straight through into master - I don't see a problem with anyone prototyping a sample string interpolation if for no other reason than to get us all thinking about how this could work in the real world (if at all). |
7sharp9
commented
Feb 3, 2016
@forki Nice work bringing this feature back to life. I think this has been discussed thoroughly in the links at the top of the page, I was really disappointed that it was dropped in F#4 when it was so close to completion. |
vasily-kirichenko
commented
Feb 3, 2016
I think it should be string interpolation (as it's in C#), not |
forki
commented
Feb 3, 2016
@vasily-kirichenko yes that would make sense as well and unify sprintf and String.Format - since it would be already interpolated at that time. |
jarlestabell
commented
Feb 5, 2016
I assume most people here know the Scala solution to this, but just in case I want to point that one out, as I think it is quite elegant. The key point is that it has a concise syntax and is extensible. with formatting: The above examples are taken from: And plain SQL queries: (http://slick.typesafe.com/doc/3.1.1/sql.html#string-interpolation) and even things like ReactJS-like JSX/TSX xml-based syntax: (example from http://docs.scala-lang.org/sips/completed/string-interpolation.html) |
enricosada
commented
Feb 5, 2016
@jarlestabell scala syntax and extensibility it's really interesting, @jarlestabell can you post your comment in the string interpolation discussion in f# lang design repo? fsharp/fslang-design#6 so this pr can remain focused on implementation. |
jarlestabell
commented
Feb 5, 2016
@enricosada Done, thanks! :) |
jon49
commented
Feb 18, 2016
Another option for adding formatting: It would be nice to keep the formatting options. Whether this way or the ways that were suggested above. Can't wait to get this feature. |
KevinRansom
commented
May 26, 2016
dsyme
commented
May 27, 2016
@KevinRansom Let's keep open any WIP PRs that correspond to an approved F# RFC. Inactivity is OK for RFCs - they can take months or years to get through the system. |
AviAvni
commented
Jul 3, 2016
forki
commented
Jul 6, 2016
I'm not sure if @dsyme has decided which syntax we will use? Is this
|
vasily-kirichenko
commented
Jul 6, 2016
I think we should just finally pick one of the syntaxes and release it. Finally. |
dsyme
commented
Jul 6, 2016
@vasily-kirichenko@forki@AviAvni The RFC is here: https://github.com/fsharp/FSharpLangDesign/blob/master/RFCs/FS-1001-StringInterpolation.md The basic proposed syntax is covered there. However the RFC really needs considerable work. I'd particularly recommend that someone go over all the comments in this thread, and in the RFC discussion thread, and the original codeplex thread, and capture all the remaining issues and list them at the end of the RFC. We can then resolve them one by one. |
vasily-kirichenko
commented
Jul 12, 2016
The implementation works with string expressions only because of forki@6542316#diff-5b9ab9dd9d7133aaf23add1048742031R6583 where coercion from mkCoerceIfNeeded cenv.g cenv.g.obj_ty cenv.g.string_ty sWhat we need here is real type of each expression |
KevinRansom
commented
Nov 8, 2016
Closing |
isaacabraham
commented
Nov 8, 2016
@KevinRansom again - why has this been closed? |
dsyme
commented
Nov 9, 2016
@isaacabraham Same response as here #908 (comment). The issue is tracked by an RFC which is definitely still active, and we can resubmit this work (or a variation of it) for F# 4.2 |
realvictorprm
commented
Sep 14, 2017
I'm going to rebase this on master again and just implement for test purposes the C# syntax. There's nothing particular wrong with extending this later again. |
@forki do you want to give me access to your PR or should I open another separate PR? |
forki
commented
Sep 14, 2017
it's closed. go ahead and submit your own |
realvictorprm
commented
Sep 14, 2017
Alright then, thank Sir! |
I "rebased" the original prototype by @v2m on the current master and made it compile.