Improved line continuation
Improved line continuation
Currently we do not have line continuation for all available operators. Extending support for the rest of them would help to be consistent.
I would also like for the '\' character to denote a newline, as this is both customarily and widely used within the Unix platform, which includes Linux, OSX, BSD, etc.
The idea is that '\' is considered a line continuation when it appears at the very end of a line with preceding whitespace and is left-adjacent to a newline. This would also be fairly clear as the '\' character is used for accessing structure members
Unfortunately, this might not be straightforward as the current evaluation of '\' allows for whitespace on either side. I would recommend that this behavior be removed if this suggestion were to be considered.
I would also like for the '\' character to denote a newline, as this is both customarily and widely used within the Unix platform, which includes Linux, OSX, BSD, etc.
The idea is that '\' is considered a line continuation when it appears at the very end of a line with preceding whitespace and is left-adjacent to a newline. This would also be fairly clear as the '\' character is used for accessing structure members
Unfortunately, this might not be straightforward as the current evaluation of '\' allows for whitespace on either side. I would recommend that this behavior be removed if this suggestion were to be considered.
Re: Improved line continuation
I agree and I think '\' would be a good choice. The ambiguity problem could be resolved
if the parser just checked whether else other than whitespace. If there is anything else,
'\' is the structure access operator, otherwise it's the new-line indicator.
I think the current behavior is a little restricted and not flexible enough, so I +1 this.
if the parser just checked whether else other than whitespace. If there is anything else,
'\' is the structure access operator, otherwise it's the new-line indicator.
I think the current behavior is a little restricted and not flexible enough, so I +1 this.
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Re: Improved line continuation
There's currently too many line-continuation characters as it is.
When the feature got added, I was excited, but shocked to see
about 5 supported.
Maybe the feature could be changed to use only one character
that the user can specify themselves in the prefs. Then, if the
last two characters of any line end with a space + that char,
the line continues.
I personally would set my prefs to use space + underscore,
just like Visual Basic. Anyway, just an idea.
When the feature got added, I was excited, but shocked to see
about 5 supported.
Maybe the feature could be changed to use only one character
that the user can specify themselves in the prefs. Then, if the
last two characters of any line end with a space + that char,
the line continues.
I personally would set my prefs to use space + underscore,
just like Visual Basic. Anyway, just an idea.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: Improved line continuation
A preference setting would be a terrible idea as it would break all compatibility.
Currently, PB just checks whether the last character is an operator and then continues
to parse the expression on the next line if it found one.
Currently, PB just checks whether the last character is an operator and then continues
to parse the expression on the next line if it found one.
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Re: Improved line continuation
I would honestly prefer to use only the '\' character for line continuation to remove ambiguity. It makes more sense to have just a single line continuation operator rather than several, since we can't arbitrarily break a line at any given whitespace.
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Improved line continuation
In BASIC flavpours, '_' is traditionally used for this purpose. That's why I personally would prefer that character.Mistrel wrote:I would also like for the '\' character to denote a newline
Currently, PB has no character that denotes a line-continuation at all.PB wrote:There's currently too many line-continuation characters as it is.
When the feature got added, I was excited, but shocked to see
about 5 supported.
The current principle is, that line-continuation is allowed after certain operators.
These operators can be in the middle of a line as well, though.
... on the system of that very user.PB wrote:Maybe the feature could be changed to use only one character
that the user can specify themselves in the prefs. Then, if the
last two characters of any line end with a space + that char,
the line continues.
All other users who would have defined a different line-continuation character in their prefs, would not be able to run that code.
So exchange of code (e.g. here on the forum) would be unnecessarily laborious.
Re: Improved line continuation
Considering this is the only flavor of Basic that I use on a regular basis, I wouldn't know. I find '_' as a line-continuation character to be an eyesore. Using '\' feels more graceful, as though it's directing my eyes downward as I glance over it. When I see '_' my brain hits against it like a brick wall. Can't go down-- there is a line in my way!Little John wrote:In BASIC flavpours, '_' is traditionally used for this purpose. That's why I personally would prefer that character.
But then again, I also wish PureBasic supported OO programming. It's up to Fred in the end.
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Improved line continuation
It's simply a matter of fact.Mistrel wrote:Considering this is the only flavor of Basic that I use on a regular basis, I wouldn't know.Little John wrote:In BASIC flavpours, '_' is traditionally used for this purpose. That's why I personally would prefer that character.
Re: Improved line continuation
Don't rock the boat.Little John wrote:It's simply a matter of fact.
Re: Improved line continuation
I forgot that making it a pref would prevent code-sharing. Sorry!
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
-
- User
- Posts: 66
- Joined: Mon Nov 11, 2013 11:07 am
- Location: Portugal
Re: Improved line continuation
Might
be a solution that fits all needs and is simply to implement?
I do miss a line coninuation a lot and would be happy with any complete solution.
KR
Code: Select all
Enable LineContinuation " _" ; or " \"
I do miss a line coninuation a lot and would be happy with any complete solution.
KR
Re: Improved line continuation
This is still very annoying.
See here:
If this were on one line I'd have to scroll horizontally to see that the "if" statement was:
This looks like a good candidate for line splitting!
But I still have to scroll horizontally because I can't see if it's a logical OR or AND.
Sigh.
Wishing for the following syntax:
See here:
If this were on one line I'd have to scroll horizontally to see that the "if" statement was:
Code: Select all
If Not CompareMemory() Or Not CompareMemory()
Code: Select all
If Not CompareMemory() Or
Not CompareMemory()
Sigh.
Wishing for the following syntax:
Code: Select all
If Not CompareMemory() \
Or Not CompareMemory()
Last edited by Mistrel on Sat Dec 09, 2017 9:39 pm, edited 3 times in total.
Re: Improved line continuation
+1 for the \backslash (and not for the _underscore)
Re: Improved line continuation
Please no '\'. To many key to pressed on macOS
I think is not a problem with '{space}_' for line wrap
I think is not a problem with '{space}_' for line wrap
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Improved line continuation
Thanks Al_the_dutch.Al_the_dutch wrote:Might
be a solution that fits all needs and is simply to implement?Code: Select all
Enable LineContinuation " _" ; or " \"
I do miss a line coninuation a lot and would be happy with any complete solution.
KR
I like your idea of a new command: EnableLineContinuation " _" (or other combination)
The user can do nothing (keep the existing code as is) or the user can override PureBasic's normal preference.
The EnableLineContinuation character(s) would stay in effect only for source code that contains this command.
This way code can be distributed without fear that it won't work on another machine.
- It was too lonely at the top.
System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem