Am 03.07.2019 um 15:29 schrieb Ben Grasset:
This has been discussed I think several times in the past, but I
thought I'd bring it up once more as it has never made sense to me
that FPC happily supports multi-line *comments* of any length, while
having no such multi-line equivalent for string literals.
I was fiddling around with what the clearest, easiest-to-parse, and
most similar-to-existing-syntaxes way of doing it would be, and came
up with this:
const MultiLineString = (##
'The
line
endings
would
be
implicit
here.
This
is
significantly
cleaner
looking
overall
IMO!'
##);
I use an operator overload(not for constants but inside the code)
because I'm used to our script engine have the '/' as operator for
strings as line break
operator / (a,b: string): string;
operator/(a, b: string): string;
begin
Result := a + #13#10 + b;
end;
var
MultiLineString: string;
begin
MultiLineString :=
'this'/
'is'/
'a'/
'multiline';
// or even shorter:
MultiLineString := 'this'/'is'/'a'/'multiline';
end;
I would like to have such feature, but then with '/' as operator because
then you can use that also inside a normal commandline
writeln('1st line'/'second line');
Greetings,
Marcus
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel