[fpc-devel] Some thoughts on multi-line string support, and a possible syntax that I think is perfectly clean and Pascal-ish.

Tomas Hajny XHajT03 at hajny.biz
Sun Jul 7 10:20:32 CEST 2019


On 2019-07-06 23:37, Ben Grasset wrote:
> On Sat, Jul 6, 2019 at 5:17 PM Ben Grasset <operator97 at gmail.com> 
> wrote:
> 
>> You cannot, in my opinion at least, reasonably expect something like 
>> this
>> to *ignore* all indentation and still function in any logical way. 
>> That the
>> leading whitespace is taken at "face value" is a large part of what 
>> makes
>> it useful for anything at all.
>> 
> 
> That said: it may, eventually, be possible for me to add an additional
> directive taking a number that indicates how many spaces to *remove* 
> from
> the beginning of a line (but never add.)
  .
  .

Personally, I don't think that such a directive is worth the effort, 
because _if_ any indentation should be supported for these strings, it 
would only make sense to indent them to the same level as the 
surrounding code (which may differ obviously). From this point of view, 
a directive allowing to trim leading whitespaces from them would make 
more sense (but even that is not that much necessary as far as I can 
tell).

BTW, should you consider creating such a directive, it should probably 
allow something like the following (to provide means to have a leading 
space where necessary):

{$MULTILINESTRINGS INDENTED} (* Just invented ;-) *)
const
   MultilineString = `Line 1
                      Line 2
                      `#32`Line 3 with one leading space`;
WriteLn (MultilineString);

... resulting in:

Line 1
Line 2
  Line 3 with one leading space

Tomas


More information about the fpc-devel mailing list