Recent

Author Topic: If you've ever wanted to be able to use multi-line strings in FPC...  (Read 5890 times)

Zoran

  • Hero Member
  • *****
  • Posts: 1456
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #120 on: July 21, 2019, 01:38:49 pm »

Hah, really! I wouldn't expect this to be ascii.

...What? Of course it is. Character number 96.

I am sorry I hadn't checked that in the first place. As I already admitted, the fact that it is ASCII is a strong point for it.

Anyway, I'm still saying that it is too similar to single quote which is used for "old style" strings, but I also have to admit we don't have much ASCII chars that are not already part of Pascal syntax left.


Perhaps tilde ("~" -- also ASCII)?

Oh, so I can waste even more time arguing with all of the Nitpick McGees out there who would definitely be very vocal with regards to complaining about how "weird" it looks to them or whatever? Yeah, no thanks.

Again, this is a moot point, now, anyways: I have literally zero intention of making that kind of fundamental change at this stage. It's not gonna happen. I've based my implementation around what was discussed (at length!) on the mailing list, and that's how at the very least the core of it is going to stay.

Akira, there is no need for this tone. I want to say what I think, that is all.

You are the one who took the effort to implement this, so from the moment I entered this topic, I have understood quite well that it is you and the core team who will decide what syntax will enter the language, it won't be me.

And, I would expect that now is still not too late for some changes, but of course only if you and the core fpc team agree with my points; otherwise you just won't accept them.

Nevertheless, I think that this topic is the right place to say what I think about it.

jamie

  • Hero Member
  • *****
  • Posts: 1742
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #121 on: July 21, 2019, 04:04:24 pm »
  Personally I think this whole concept and what is being done is just a push to make fpc a database  scripting compiler which in my opinion takes it away from what it should be..

 I views as with many others here have no weight in the decision making so i'll sit and watch the many kacks
being done to turn it into a scripting compiler.

  I can think of much better things to be doing with the compiler than making it a script kiddy editor..

 I just pray there will always be switches to turn it off and keep it off..
 
 My self, I've always had a tool around that created a pascal line by line block of text like that I could edit
off the side and then simply paste it into the editor.. It works for Delphi and it works for Lazarus thus keeping
it the pascal style and also, it will back paste into the side editor for rework...

 I really think this should be done in Lazarus as a tool option and not in the compiler but who am I right? Just another out there like many here. := Noise;




Zoran

  • Hero Member
  • *****
  • Posts: 1456
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #122 on: July 21, 2019, 05:50:40 pm »
Do note also:

Once this functionality gets merged to FPC, I then intend to submit a patch I have for Lazarus SynEdit which makes it highlight multi-line strings much the way it does multi-line comments right now.
(Of course, I know not everyone uses Lazarus, but it's something.)

I hope you will also take care of "Trim trailing spaces" IDE option, which has always been safe to use with Pascal source, but now it will have to take care not to brake new style string literals.


Akira1364

  • Hero Member
  • *****
  • Posts: 521
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #123 on: July 21, 2019, 06:10:48 pm »
Akira, there is no need for this tone. I want to say what I think, that is all.

You are the one who took the effort to implement this, so from the moment I entered this topic, I have understood quite well that it is you and the core team who will decide what syntax will enter the language, it won't be me.

Sorry if that came off overly harsh. It's just that you need to keep in mind the "big picture":

For example, I am 100% sure that if, for some reason, we were actually planning on using the tilde character to denote multiline strings, the amount of controversy around the whole thing would be an order of magnitude larger than it is now.

I hope you will also take care of "Trim trailing spaces" IDE option, which has always been safe to use with Pascal source, but now it will have to take care not to brake new style string literals.

That IDE option does not need to change in any way at all. I don't understand why you think it would "break" multi-line strings. I've specifically tested it, and it does in fact trim the trailing space if turned on (as it should) but this does not alter the way a multiline string is ultimately formatted / appears when displayed with WriteLn, e.t.c.

If you were someone who actually literally wanted real trailing whitespace (despite the fact that, again, the string will look exactly the same whether it is there or not), the answer is obviously "turn that IDE option off when necessary."

Note: it is probably feasible to tweak that feature a bit so that it does indeed actually "ignore" multi-line strings. This might be a useful thing to do, at some point. I'm sure I could probably do it myself, and may well do so at some point down the line. One thing at a time however.

This general idea that I've implemented the multi-line strings functionality in some fragile way full of "gotchas" that's ready to fall apart at any moment is rather annoying, though.

Will both strings be the same?

For the last time, if using {$MultiLineStringTrimLeft Auto}, yes, the output would be completely identical in that case.

And you have to recognize that the multiline string is much less readable

I really do not.

how many spaces are there?

This is not some mysterious edge case. I have explained exactly how it works over, and over, and over, and over again. There's exactly as many spaces as what's actually present, unless you're trimming the leading ones in a way of your choosing with the MultiLineStringTrimLeft directive.

Also, @Jamie:

Sorry, but I'm not going to waste any more of my time responding at length to your childish hyperbole.
« Last Edit: July 22, 2019, 12:24:24 am by Akira1364 »

jamie

  • Hero Member
  • *****
  • Posts: 1742
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #124 on: July 21, 2019, 06:45:51 pm »
Personally I wish you would stop making the compiler what it isn't and move that work over where it should
be and that is the IDE.

  if you feel I am being childish about this, I think you're in for a rude awaking. I am only posting what many others are thinking. I wasn't brought up to be politically correct just to appease those that would go against
the many to please a few.

  I fully agree with many here that have had negative views about what is going to take place.. And I see the code tools along with some components used in Lazarus taking a major overhaul just to make this work.

  You may find it hard to believe, but there are actually very knowable users posting here that uses the tools and can point out many issues that may or will take place , especially in the IDE code tools. But you claim you have it all under control as you indicated in  your replies.

 I can see I'll be sticking with the 2.0.2 and 3.0.2 for some time now. I can't say what others will be doing but for me "Since I've written compilers and IDE's " this isn't happening to soon.

 And btw, I use the SynEdit extensively in some critical editing tools where line formatting and function of the component as it is now is very important.

 Have a good day, and thank you for letting me express myself, as worthless as it is..


Akira1364

  • Hero Member
  • *****
  • Posts: 521
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #125 on: July 21, 2019, 07:15:18 pm »
- snip -

You're just oozing FUD here. Nobody who actually understood how I'd implemented the multi-line strings functionality (something they can of course see for themselves, as the source is very available!) would think any tool would require anything resembling a "major overhaul" in order to support it. It took me literally less than 10 minutes to make SynEdit highlight them properly in my local checkout of Lazarus, for example.
« Last Edit: July 22, 2019, 12:27:45 am by Akira1364 »

Zoran

  • Hero Member
  • *****
  • Posts: 1456
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #126 on: July 21, 2019, 07:48:29 pm »

That IDE option does not need to change in any way at all. I don't understand why you think it would "break" multi-line strings.

I would expect it to trim trailing spaces from the first line of two-line string literal.
You are sure it will not? Why not? We haven't had significant trailing spaces in Pascal source until now, so I would not expect this utility to have a clever way to decide which trailing spaces should be kept in source.

This general idea that I've implemented the multi-line strings functionality in some fragile way full of "gotchas" that's ready to fall apart at any moment is rather annoying.

I am sorry to annoy you. I just would really expect this IDE option to trim all trailing spaces from the source, even when they finish the line inside multiline string.
I would never say a small "gotcha" like this could lead the whole new feature to fall apart. ;)

For example, I am 100% sure that if, for some reason, we were actually planning on using the tilde character to denote multiline strings, the amount of controversy around the whole thing would be an order of magnitude larger than it is now.


Yes, I believe it would.
I admit that the only thing I really don't like is the possibility to have significant spaces on the end of the line, for the first time in Pascal history. I find it much more annoying than the choice of "backtick" character, which I criticized for resembling single quote too much, but I can accept it, actually it is eventually quite fine with me.

Akira1364

  • Hero Member
  • *****
  • Posts: 521
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #127 on: July 22, 2019, 12:16:09 am »
I would expect it to trim trailing spaces from the first line of two-line string literal.

It does. Why wouldn't it?

I am sorry to annoy you. I just would really expect this IDE option to trim all trailing spaces from the source, even when they finish the line inside multiline string.
I would never say a small "gotcha" like this could lead the whole new feature to fall apart. ;)

Again, that option does still do that in that scenario, currently.

My point was that this does not "break" the appearance of the multi-line string when displayed at runtime and is overall essentially irrelevant, because you can't actually visually tell if there are or are not trailing spaces in it regardless.

If you actually wanted trailing spaces, for some reason, as it stands now you would just turn that IDE option off, as has always been the case.
« Last Edit: July 22, 2019, 12:20:37 am by Akira1364 »

Zoran

  • Hero Member
  • *****
  • Posts: 1456
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #128 on: July 22, 2019, 01:40:11 am »
I would expect it to trim trailing spaces from the first line of two-line string literal.

It does. Why wouldn't it?

Why?
Because that changes the string. The trailing spaces are the part of the string, they get lost...
Are you serious? :o

My point was that this does not "break" the appearance of the multi-line string when displayed at runtime and is overall essentially irrelevant, because you can't actually visually tell if there are or are not trailing spaces in it regardless.
You say when you display string on the screen, it does not matter if trailing spaces are cut off, it appears the same.
You surely understand that strings can be used for purposes not so trivial as to be just displayed on the screen.

It changes the string literal, and the fact that you can't actually visually tell if there are or not trailing spaces is the essence of the problem - you will not notice the change.

If you actually wanted trailing spaces, for some reason, as it stands now you would just turn that IDE option off, as has always been the case.
If for some reason I actually want trailing spaces in the multiline string literal, I will surely not use the new style syntax. But someone will.

And some day I will open some unit from some library written by someone -- a unit which has a new syntax string literal with trailing spaces, and the IDE will just change this string. I will open that unit to see some other code, some function far from that string, I will not be aware of the string existence.
And of course that could seriously affect the programme behaviour.

Akira1364

  • Hero Member
  • *****
  • Posts: 521
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #129 on: July 22, 2019, 02:13:15 am »
If for some reason I actually want trailing spaces in the multiline string literal, I will surely not use the new style syntax. But someone will.
And some day I will open some unit from some library written by someone -- a unit which has a new syntax string literal with trailing spaces, and the IDE will just change this string. I will open that unit to see some other code, some function far from that string, I will not be aware of the string existence.
And of course that could seriously affect the programme behaviour.

Ah, the old "contrived problem that almost certainly will never, ever actually occur as described in real life, and is highly unlikely to be a significant issue if it did due to what the vast majority of likely use cases for the feature are" tailor-made scare-mongering. Yawn.

The bottom line is:

I have literally said I could probably modify that feature of Lazarus to ignore multi-line strings without too much of an issue, and that I would be willing to do so (despite the fact I generally disagree that FPC needs to specifically cater to arbitrary Lazarus IDE features. They are two separate things.)

I do not however believe that 99% of the people who will ever use multi-line strings will do so in a way where the existence or non-existence of trailing whitespace between the last visible character and the newline character will actually matter to them in any way whatsoever, due to the fundamental nature of what strings are used for in the vast majority of cases (i.e. displaying information!)

This is of course very different from leading whitespace, which does indeed affect the formatting (hence why I introduced the MultiLineStringTrimLeft directive.)

We are talking about a programming language where anybody can, for example, just casually drop into inline assembly in the middle of their Button.OnClick() regardless of whether or not they have any idea what they're doing, and cannot reasonably expect the compiler or Lazarus to "save them from themselves" in the event they screw something up. And this is fine! It is what separates Pascal from nominally "safer" but objectively less powerful languages such as Java, e.t.c.

This is mind, do you not see how ridiculous it is to then apply this massive double standard that treats strings as way more critical than they ever commonly are in reality, and goes "it is unacceptable if every editor that anyone might ever code Pascal in does not fully and entirely account for this new language feature IMMEDIATELY!"

Am I supposed to go and start writing Vim / Emacs / Sublime Text / Visual Studio Code / e.t.c. plugins just to really make sure no poor, innocent programmer blows their leg off while using these dangerous, complicated multi-line strings (because it's not like their editor configuration is their own responsibility! That's crazy!) then? Where does it end?

Even if no editor ever directly supported multi-line strings in any capacity, the chances of their use in a codebase causing you any kind of serious problem is remarkably low, and it is disingenuous to claim otherwise.
« Last Edit: July 22, 2019, 06:20:21 pm by Akira1364 »

SlightlyOutOfPhase

  • New member
  • *
  • Posts: 33
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #130 on: July 22, 2019, 03:33:06 am »
I think these feature is very nice.

if any one has issue they should avoid using it.

But we should encourage people who contributing to FPC development.

More contribution to FPC means much much better PROGRAMMING LANGUAGE/PLATFORM
it benefit to EVERYONE.

+1.

if you feel I am being childish about this, I think you're in for a rude awaking. I am only posting what many others are thinking. I wasn't brought up to be politically correct just to appease those that would go against
the many to please a few.

If we are all not "being politically correct to please people" here, then I'm just going to straight up say that EVERYTHING you have said in this thread makes you sound like a fucking idiot. All of your comments are embarrassing, and anyone who agrees with you is equally stupid. You are NOT "the many".

People like you are DIRECTLY what causes FPC's slow, inevitable decline in popularity. It's the same fucking thing every fucking time anybody wants to introduce anything new: a bunch of illiterate morons spouting off conspiracy-theory nonsense about how the sky is falling, who are ALWAYS, ALWAYS, ALWAYS clearly wrong in hindsight. You can go wayyyyy back on the developer mailing list for FPC and find people who unironically argued against the introduction of for-in loops the same fucking way you're arguing against this strings feature, back in like 2006. I'm not kidding. For-in loops! How fucking insane does that sound now that they've been a normal part of the language for years? Very!

So yeah, for the love of god stop fucking driving away smart people who both want to improve FPC and can also actually do the work themselves, or sometime real soon there won't be anyone left working on it at all.

Imants

  • Full Member
  • ***
  • Posts: 178
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #131 on: July 22, 2019, 07:48:43 am »
I think these feature is very nice.

if any one has issue they should avoid using it.

But we should encourage people who contributing to FPC development.

More contribution to FPC means much much better PROGRAMMING LANGUAGE/PLATFORM
it benefit to EVERYONE.

+1.

if you feel I am being childish about this, I think you're in for a rude awaking. I am only posting what many others are thinking. I wasn't brought up to be politically correct just to appease those that would go against
the many to please a few.

If we are all not "being politically correct to please people" here, then I'm just going to straight up say that EVERYTHING you have said in this thread makes you sound like a fucking idiot. All of your comments are embarrassing, and anyone who agrees with you is equally stupid. You are NOT "the many".

People like you are DIRECTLY what causes FPC's slow, inevitable decline in popularity. It's the same fucking thing every fucking time anybody wants to introduce anything new: a bunch of illiterate morons spouting off conspiracy-theory nonsense about how the sky is falling, who are ALWAYS, ALWAYS, ALWAYS clearly wrong in hindsight. You can go wayyyyy back on the developer mailing list for FPC and find people who unironically argued against the introduction of for-in loops the same fucking way you're arguing against this strings feature, back in like 2006. I'm not kidding. For-in loops! How fucking insane does that sound now that they've been a normal part of the language for years? Very!

So yeah, for the love of god stop fucking driving away smart people who both want to improve FPC and can also actually do the work themselves, or sometime real soon there won't be anyone left working on it at all.

Totally agree with your statement.

Akira1364

  • Hero Member
  • *****
  • Posts: 521
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #132 on: July 24, 2019, 04:14:04 am »
Came across another area today where I think multi-line strings would be quite helpful to a lot of people: writing tests!

For example, the FCL-Passrc package that comes with FPC has a rather large test suite with hundreds of procedures that take source code in string form as input. Currently, almost all of these procedures have to do this via an overload of the test input method that takes an open array of many single-line strings. You can see what this looks like in the first image I've attached to this comment "Current.png".

However, with multi-line strings, you can simply pass a lone constant to the overload of the test input method that actually takes a string directly, which is easier to write, and also means less runtime overhead for the test as well as a smaller executable for the test. You can see what that looks like (in my patched Lazarus) in the second image I've attached, "WithMultiLine.png".

There's an additional benefit also: since multi-line strings can be folded in Lazarus, this allows you to reduce a lot of screen clutter when / where you want to. You can see what that looks like in the third image I've attached, "Folded.png."
« Last Edit: July 24, 2019, 04:39:53 am by Akira1364 »

Awkward

  • New member
  • *
  • Posts: 47
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #133 on: July 24, 2019, 05:55:33 am »
Than farther, then more looks like you want to realize just your wishes but not worrying about other people and language. Please, stop to lobby your wishes! Keep pascal as pascal.

440bx

  • Hero Member
  • *****
  • Posts: 1047
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #134 on: July 24, 2019, 06:33:46 am »
@Akira

Came across another area today where I think multi-line strings would be quite helpful to a lot of people: writing tests!
There is no doubt that the feature you're adding makes multiline strings significantly more readable and easier to insert in code.


@Awkward

Keep pascal as pascal.
could you explain how this feature leads to not "keep pascal as pascal" ?
« Last Edit: July 24, 2019, 06:46:31 am by 440bx »
using FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.