Page 1 of 2

Improved line continuation

Posted: Sat Nov 22, 2014 1:36 am
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.

Re: Improved line continuation

Posted: Sat Nov 22, 2014 12:12 pm
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.

Re: Improved line continuation

Posted: Sat Nov 22, 2014 12:17 pm
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. :)

Re: Improved line continuation

Posted: Sat Nov 22, 2014 1:10 pm
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.

Re: Improved line continuation

Posted: Sat Nov 22, 2014 1:15 pm
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.

Re: Improved line continuation

Posted: Sat Nov 22, 2014 1:20 pm
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.

Re: Improved line continuation

Posted: Sat Nov 22, 2014 1:28 pm
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.

Re: Improved line continuation

Posted: Sat Nov 22, 2014 1:38 pm
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.

Re: Improved line continuation

Posted: Sat Nov 22, 2014 1:40 pm
by Mistrel
Little John wrote:It's simply a matter of fact.
Don't rock the boat. :wink:

Re: Improved line continuation

Posted: Sat Nov 22, 2014 2:34 pm
by PB
I forgot that making it a pref would prevent code-sharing. Sorry!

Re: Improved line continuation

Posted: Mon Oct 17, 2016 9:29 am
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

Re: Improved line continuation

Posted: Thu Nov 16, 2017 2:04 am
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()

Re: Improved line continuation

Posted: Fri Nov 17, 2017 3:14 pm
by #NULL
+1 for the \backslash (and not for the _underscore)

Re: Improved line continuation

Posted: Fri Nov 17, 2017 7:13 pm
by mk-soft
Please no '\'. To many key to pressed on macOS :mrgreen:

I think is not a problem with '{space}_' for line wrap

Re: Improved line continuation

Posted: Sat Nov 18, 2017 12:26 pm
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. :)