Recent

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

PascalDragon

  • Hero Member
  • *****
  • Posts: 1703
  • Compiler Developer
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #150 on: August 10, 2019, 01:16:14 pm »
I only take exception to code like this:
Code: Pascal  [Select][+][-]
  1. if (c in ['1'..'9']) then // <------ sigh
  2.           begin
  3.             count:=current_scanner.readval;
  4.             if (count<0) or (count>65535) then // <------- sigh some more
Both the range and the limit. See if you can spot what I mean  :o

In my view the functionality is already covered by the string helper in sysutils and without an artificial limit. Let alone the meaning of "word"..
Okay, the range for c should start from '0' as other directives allow leading zeros as well, but that's all we're talking about here: detecting leading zeros. The complete number is read by readval.
And using High(Word) instead of the literal 65535 would indeed be nice as well.

That said there has been no decision yet whether we want to allow the use of helpers (or generics for that matter) inside the compiler. Also the string helper would be useless as a) the compiler uses mainly ShortString and b) there is no Char helper.

Thaddy

  • Hero Member
  • *****
  • Posts: 10193
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #151 on: August 10, 2019, 01:57:31 pm »
@Sven
You were not supposed to bite...
I am more like donkey than shrek

Akira1364

  • Hero Member
  • *****
  • Posts: 540
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #152 on: August 10, 2019, 05:45:41 pm »
I only take exception to code like this:

"c" is one character, Thaddy. (As in, the first character of what may or may not be a valid number.) "readval" then attempts to read an actual complete number into the "count" variable.

As far as this being provided by some kind of library, that would be strictly worse, as it would be slower and could not have the capabilities it does now. As far as TStringHelper being related to this kind of thing at all, I don't get what you mean.

Okay, the range for c should start from '0' as other directives allow leading zeros as well, but that's all we're talking about here: detecting leading zeros. The complete number is read by readval.
And using High(Word) instead of the literal 65535 would indeed be nice as well.

I'll make those changes.
« Last Edit: August 10, 2019, 05:48:37 pm by Akira1364 »

Zoran

  • Hero Member
  • *****
  • Posts: 1564
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #153 on: August 10, 2019, 05:55:58 pm »
This is a dirty feature.
Don't you understand -- in Pascal, trailing spaces at the end of a line have always been insignificant.

This is important -- trailing spaces are not visible.
You cannot see them! A programming language in which spaces in the end of line can be significant is not clean, as Pascal should be.

It is very bad.

Akira1364

  • Hero Member
  • *****
  • Posts: 540
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #154 on: August 10, 2019, 06:03:13 pm »
- snip -

Read my previous comment as to why I fundamentally disagree with you.

Thaddy

  • Hero Member
  • *****
  • Posts: 10193
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #155 on: August 10, 2019, 06:06:21 pm »
"c" is one character, Thaddy. (As in, the first character of what may or may not be a valid number.) "readval" then attempts to read an actual complete number into the "count" variable.
Well, Sven knew what I meant... :D
And as far as the helper goes, look at the interface. You can achieve the same  with few lines of code. (syshelph.inc)
I am more like donkey than shrek

Zoran

  • Hero Member
  • *****
  • Posts: 1564
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #156 on: August 10, 2019, 06:10:05 pm »
- snip -

Read my previous comment as to why I fundamentally disagree with you.

I read them, of course... Nevertheless, I still hope for a little common sense...

440bx

  • Hero Member
  • *****
  • Posts: 1885
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #157 on: August 10, 2019, 07:14:19 pm »
Nevertheless, I still hope for a little common sense...
What I'm going to state isn't associated with the feature being discussed here, just a truism which is, common sense is the least common of all senses.  (as clearly evidenced in a number of threads completely unrelated to this new feature.)


FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

Akira1364

  • Hero Member
  • *****
  • Posts: 540
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #158 on: August 10, 2019, 07:50:59 pm »
Nevertheless, I still hope for a little common sense...

Right, as do I. There's mountains of evidence in various places (and various languages) as to how this kind of feature does not cause anything resembling kind of issues you're speculating about.

Also, as far as I know, my implementation of this actually goes farther than any other language's implementation does with regards to end-user customization and error handling in the case of "unterminated" multi-line strings.

ASBzone

  • Sr. Member
  • ****
  • Posts: 364
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #159 on: August 11, 2019, 06:25:41 am »
This is a dirty feature.
Don't you understand -- in Pascal, trailing spaces at the end of a line have always been insignificant.
...


Perhaps I am missing something, but this feature doesn't change that at all.

For those who do not implement it, there is zero change to trailing space significance.


To those who implement the feature, there is zero change to trailing space significance.


If someone needs trailing spaces for a regular or multi-line string, then they have to pay attention to it for the strings in question, but it will not automatically affect every string.

-ASB: https://www.BrainWaveCC.com

Lazarus v2.0.11 r63516 / FPC v3.2.1-r45705 (via FpcUpDeluxe) -- Windows 64-bit install w/32-bit cross-compile
Primary System: Windows 10 Pro x64, Version 2004 (Build 19041.329)
Other Systems: Windows 10 Pro x64, Version 1909 or greater

PascalDragon

  • Hero Member
  • *****
  • Posts: 1703
  • Compiler Developer
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #160 on: August 11, 2019, 02:00:38 pm »
@Sven
You were not supposed to bite...
It's about compiler related code, so of course I'll bite. And Akira1364 said that he'd make some adjustments...
And as far as the helper goes, look at the interface. You can achieve the same  with few lines of code. (syshelph.inc)
I still don't get though what you're trying to get at with the helpers...

heejit

  • Full Member
  • ***
  • Posts: 242
Re: If you've ever wanted to be able to use multi-line strings in FPC...
« Reply #161 on: September 14, 2019, 01:22:32 pm »
Is this FEATURE ACCEPTED BY CORE TEAM???

 

TinyPortal © 2005-2018