PureBasic Forum
https://www.purebasic.fr/english/

Improved line continuation
https://www.purebasic.fr/english/viewtopic.php?f=3&t=61025
Page 1 of 2

Author:  Mistrel [ Sat Nov 22, 2014 1:36 am ]
Post subject:  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.

Author:  Shield [ Sat Nov 22, 2014 12:12 pm ]
Post subject:  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.

Author:  PB [ Sat Nov 22, 2014 12:17 pm ]
Post subject:  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. :)

Author:  Shield [ Sat Nov 22, 2014 1:10 pm ]
Post subject:  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.

Author:  Mistrel [ Sat Nov 22, 2014 1:15 pm ]
Post subject:  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.

Author:  Little John [ Sat Nov 22, 2014 1:20 pm ]
Post subject:  Re: Improved line continuation

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.

Author:  Mistrel [ Sat Nov 22, 2014 1:28 pm ]
Post subject:  Re: Improved line continuation

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.

Author:  Little John [ Sat Nov 22, 2014 1:38 pm ]
Post subject:  Re: Improved line continuation

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.

Author:  Mistrel [ Sat Nov 22, 2014 1:40 pm ]
Post subject:  Re: Improved line continuation

Little John wrote:
It's simply a matter of fact.


Don't rock the boat. :wink:

Author:  PB [ Sat Nov 22, 2014 2:34 pm ]
Post subject:  Re: Improved line continuation

I forgot that making it a pref would prevent code-sharing. Sorry!

Author:  Al_the_dutch [ Mon Oct 17, 2016 9:29 am ]
Post subject:  Re: Improved line continuation

Might

Code:
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

Author:  Mistrel [ Thu Nov 16, 2017 2:04 am ]
Post subject:  Re: Improved line continuation

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


This looks like a good candidate for line splitting!


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

Author:  #NULL [ Fri Nov 17, 2017 3:14 pm ]
Post subject:  Re: Improved line continuation

+1 for the \backslash (and not for the _underscore)

Author:  mk-soft [ Fri Nov 17, 2017 7:13 pm ]
Post subject:  Re: Improved line continuation

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

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

Author:  blueb [ Sat Nov 18, 2017 12:26 pm ]
Post subject:  Re: Improved line continuation

Al_the_dutch wrote:
Might

Code:
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. :)

Page 1 of 2 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/