Improved line continuation

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Improved line continuation

Post by Mistrel »

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.
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: Improved line continuation

Post by Shield »

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.
Image
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
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Improved line continuation

Post by PB »

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. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: Improved line continuation

Post by Shield »

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.
Image
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
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Improved line continuation

Post by Mistrel »

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.
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Improved line continuation

Post by Little John »

Mistrel wrote:I would also like for the '\' character to denote a newline
In BASIC flavpours, '_' is traditionally used for this purpose. That's why I personally would prefer that character.
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.
Currently, PB has no character that denotes a line-continuation at all.
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.
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.
... on the system of that very user.
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.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Improved line continuation

Post by Mistrel »

Little John wrote:In BASIC flavpours, '_' is traditionally used for this purpose. That's why I personally would prefer that character.
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! :)

But then again, I also wish PureBasic supported OO programming. It's up to Fred in the end.
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Improved line continuation

Post by Little John »

Mistrel wrote:
Little John wrote:In BASIC flavpours, '_' is traditionally used for this purpose. That's why I personally would prefer that character.
Considering this is the only flavor of Basic that I use on a regular basis, I wouldn't know.
It's simply a matter of fact.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Improved line continuation

Post by Mistrel »

Little John wrote:It's simply a matter of fact.
Don't rock the boat. :wink:
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Improved line continuation

Post by PB »

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.
Al_the_dutch
User
User
Posts: 66
Joined: Mon Nov 11, 2013 11:07 am
Location: Portugal

Re: Improved line continuation

Post by Al_the_dutch »

Might

Code: Select all

Enable LineContinuation " _" ; or " \"
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
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Improved line continuation

Post by Mistrel »

This is still very annoying.

See here:

Image

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()
This looks like a good candidate for line splitting!

Code: Select all

If Not CompareMemory() Or
  Not CompareMemory()
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:

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.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Improved line continuation

Post by #NULL »

+1 for the \backslash (and not for the _underscore)
User avatar
mk-soft
Always Here
Always Here
Posts: 5313
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Improved line continuation

Post by mk-soft »

Please no '\'. To many key to pressed on macOS :mrgreen:

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
User avatar
blueb
Addict
Addict
Posts: 1037
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Improved line continuation

Post by blueb »

Al_the_dutch wrote:Might

Code: Select all

Enable LineContinuation " _" ; or " \"
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
Thanks Al_the_dutch. :)

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 Beta 7 (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Post Reply