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
On the symbolic strings PR (#994), @yannham pointed out that there's an inconsistency between how symbolic strings and multiline strings handle the interpolation of strings with multiple lines when preceded by an indent.
With multiline strings, the behaviour is as follows:
let s = "a\nb" in
m%"
begin
%{s}
end"%
results in:
begin
a
b
end
i.e., the indentation preceding the first line of the interpolated string is also applied to the following lines.
However, currently with symbolic strings this does not happen. Which is to say that this:
let s = "a\nb" in
s%"
begin
%{s}
end"%
evaluates to (with newlines written as escape characters for clarity):
[ "begin\n ", "a\nb", "\nend" ]
The question essentially is whether it might be more natural to apply the same rule here. That is, to have the symbolic string above evaluate instead to:
[ "begin\n ", "a\n b", "\nend" ]
The text was updated successfully, but these errors were encountered:
Having been educated about the (awesome!) behaviour of regular multiline strings with interpolation, I feel like we should have a way of implementing the same behaviour for symbolic strings. But I don't think selectively altering interpolated expressions, when they happen to be strings, would be the correct semantics. If we were to opt for a tagged representation of a symbolic string in Nickel these things could easily be implemented as library functions. E.g. if
let s = "a\nb" in
s%"
begin
%{s}
end
evaluates to the array
[
{ type = `Literal, value = "begin\n " },
{ type = `Interpolation, indent = 4, value = "a\nb" },
{ type = `Literal, value = "end\n" }
]
we could easily have a Nickel library function that turns { type = `Interpolation, indent = 4, value = "a\nb" } into "a\n b" if that is what's desired.
On the symbolic strings PR (#994), @yannham pointed out that there's an inconsistency between how symbolic strings and multiline strings handle the interpolation of strings with multiple lines when preceded by an indent.
With multiline strings, the behaviour is as follows:
results in:
i.e., the indentation preceding the first line of the interpolated string is also applied to the following lines.
However, currently with symbolic strings this does not happen. Which is to say that this:
evaluates to (with newlines written as escape characters for clarity):
The question essentially is whether it might be more natural to apply the same rule here. That is, to have the symbolic string above evaluate instead to:
The text was updated successfully, but these errors were encountered: