# PureBasic Forum

 It is currently Sat Jan 20, 2018 8:10 am

 All times are UTC + 1 hour

 Page 2 of 2 [ 30 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
Author Message
 Post subject: Re: Improved line continuationPosted: Sat Dec 09, 2017 9:45 pm

Joined: Sat Jun 30, 2007 8:04 pm
Posts: 3116
Still very frustrated with this.

As I break lines to try and simplify things I keep running into strange logic when reading quickly such as "If Not Not" which makes no sense rather than "If Not Or Not" or "If Not And Not". This forces me to break context with whatever I was doing either in a WTF moment or from the pure necessity of scrolling. But then after I return to scrolling vertically I've lost all reference as there may be conflicting logic that I can't see from other lines.

Please, please, please provide a solution for this. PureBasic is the only language I use that I cannot keep at under 80 columns for clarity.

Thank you.

viewtopic.php?f=3&t=66631

_________________

Top

 Post subject: Re: Improved line continuationPosted: Sun Dec 10, 2017 5:13 pm
 Enthusiast

Joined: Tue Apr 24, 2012 5:08 pm
Posts: 542
It seems to me that the only logical solution to this problem is to add the " _ " as a valid continuation character.

I've been using BASIC since it was invented in the 1960's, and the underscore char has been used for line continuation for as long as I can remember. Other characters like "+" and "," are not always available in the line of code in order to create suitable break points.

Rod

_________________
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan

Top

 Post subject: Re: Improved line continuationPosted: Sun Dec 10, 2017 7:44 pm

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2550
Location: Boston, MA
This topic never ends.
Why not force a line end character(;) like C, Pascal, and many others?

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum

Top

 Post subject: Re: Improved line continuationPosted: Sun Dec 10, 2017 8:57 pm
 Enthusiast

Joined: Tue Apr 24, 2012 5:08 pm
Posts: 542
skywalk wrote:
This topic never ends.

The reason is that, with nearly 1,000,000 lines of PowerBasic code to convert, it would be nice to have one less thing to worry about.

Code:
Sub subDefineFile Alias "dvs6069DefineFile"   _
( ByRef bruHcb            As udtIsamHcb  _    ' 14869 : isam file handle control block
, ByVal bvnFileNumber     As DWORD       _    ' 10526 : file number: 1 - 999
, ByRef brsIsamFileName   As STRING      _    ' 15557 : isam file descriptive name
, ByRef brsFilePath       As STRING      _    ' 15040 : generic file path
, ByVal bviRecordLength   As LONG        _    ' 14691 : file record length
, ByVal bvnFieldCount     As DWORD       _    ' 11241 : number of data fields
, ByVal bviIndexCount     As LONG        _    ' 11240 : number of indexes
) Export

_________________
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan

Top

 Post subject: Re: Improved line continuationPosted: Mon Dec 11, 2017 12:58 am

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2550
Location: Boston, MA
Code:
Procedure x(a,    ; a something
b,    ; b something
c,    ; c something
d,    ; d something
e)    ; e something
ProcedureReturn a
EndProcedure
Certainly, your parser/translator app can handle this? The current line continuation method was not available when I started using PB, so I appreciate it as is. I'm still waiting on block comments.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum

Top

 Post subject: Re: Improved line continuationPosted: Mon Dec 11, 2017 1:40 am
 Enthusiast

Joined: Tue Apr 24, 2012 5:08 pm
Posts: 542
skywalk wrote:
Certainly, your parser/translator app can handle this?

Yes, but the code generators still have to be changed to handle PB's non-standard syntax. It would be nice if there were fewer differences. However, PB is a powerful product, so I don't mind the extra work.

We've now created almost 500 macros (and counting) in order to keep our code highly structured and easy to read. Here's what the above PowerBasic code looks like now:

Code:
ExternalSubroutine(DefineFile) ( ByBlk(bruHcb,          udtIsamHcb),   ; 14869 : isam file handle control block
ByVal(bvnFileNumber,   typDword),     ; 10526 : file number: 1 - 999
ByRef(bvsIsamFileName, typString),    ; 15557 : isam file descriptive name
ByRef(bvsFilePath,     typString),    ; 15040 : generic file path
ByVal(bviRecordLength, typInt32),     ; 14691 : file record length
ByVal(bvnFieldCount,   typDword),     ; 11241 : number of data fields
ByVal(bviIndexCount,   typInt32) )    ; 11240 : number of indexes

Rod

_________________
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan

Top

 Post subject: Re: Improved line continuationPosted: Wed Dec 13, 2017 1:48 am

Joined: Sat Jun 30, 2007 8:04 pm
Posts: 3116
What if a space and a semi-colon followed by a newline to indicated a line continuation? This is both backwards compatible and is unlikely to cause issues with older code as there is little reason for anyone to actually do this in practice.

It should also be fairly clear for those already familiar with languages which require the use of a semi-colon to indicate the end of a line. IMO, it's an obvious winner.

Code:
If Not CompareMemory() ;
Or Not CompareMemory()

_________________

Top

 Post subject: Re: Improved line continuationPosted: Wed Dec 13, 2017 3:29 am

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2550
Location: Boston, MA
Sorry, but a trailing semicolon already indicates comments. This would create a parsing logic sinkhole.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum

Top

 Post subject: Re: Improved line continuationPosted: Wed Dec 13, 2017 5:29 am

Joined: Fri Jan 21, 2011 8:25 am
Posts: 1009
Location: 'stralia!
It wouldn't work, because the compiler would have to treat anything after a semicolon (i.e. comment) as a continuation, so it would inevitably break all code.

Code:
If a ;
Debug a
EndIf

Would have to be treated as

Code:
If a Debug a
EndIf

_________________

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

Top

 Post subject: Re: Improved line continuationPosted: Wed Dec 13, 2017 6:59 pm

Joined: Sat Jun 30, 2007 8:04 pm
Posts: 3116
I think you misunderstand. The semi-colon will remain the comment symbol but if it appears as the end of a line and immediately followed by a newline then it will instead be treated as a line continuation symbol.

THIS indicates line continuation because it is a semi-colon followed immediately by a newline:

Code:
If a ;
Debug a
EndIf

THIS is still a comment because the semi-colon does not appear at the end of the line:

Code:
; This is a comment but below will be for line-continuation
If a ;
Debug a
EndIf

This works because there should be very little use-case for a bare semi-colon comment. But if you want to be fancy, just add a space:

Code:
;
; This is still OK
;
; Because there are spaces
;

But even in events where spaces are not present, it will works if the following line is a comment:

Code:
; This is also OK
;
; Because it's just continuing a comment

It really is an elegant, backwards-compatible solution that is also similar to other languages use of ';' to indicate the end of a line. I think it's perfect.

_________________

Top

 Post subject: Re: Improved line continuationPosted: Wed Dec 13, 2017 7:09 pm
 Enthusiast

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 670
Location: right here
it's the opposite of perfect. looks like an empty comment but isn't, and does the opposite as in other languages: split one command into multiple lines, instead of separating multiple commands from each other [on the same line].

Top

 Post subject: Re: Improved line continuationPosted: Thu Dec 14, 2017 7:56 am
 Enthusiast

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 605
For some years now we have line-continuation with (+), (,), (|), And, Or, Xor. Whether this was the best decision or whether a simple underscore like used in VB6 would be better is a question. It was a decision with which I can actually live quite well.

In any case, each program can assume a certain minimum hardware configuration. When I look at this image, a screen where there are only 60 characters per line for code is not one of them.

I don't understand why an already exhausted thread based on insufficient hardware has to be kept alive with even more stupid suggestions like a semicolon as line-continuation.

_________________

Top

 Post subject: Re: Improved line continuationPosted: Thu Dec 14, 2017 8:15 am

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1105
Mistrel wrote:
This looks like a good candidate for line splitting

On such a small screen size that you're using (60 chars per line), you have three additional options:

(1) A smaller font size.
(2) A font that is proportional instead of fixed-width.
(3) Auto-hiding of the procedure panel in the IDE Settings.

Using all 3 of these will greatly provide more visible characters per line for you.

Top

 Post subject: Re: Improved line continuationPosted: Thu Dec 14, 2017 1:55 pm

Joined: Fri Jan 21, 2011 8:25 am
Posts: 1009
Location: 'stralia!
Limiting lines to 80 characters (not 60) is actually really common and has little to do with screen size
but with readability. Reading code that has excessively long lines is a nightmare.

@Mistrel
Alright, I get now what you mean. It's still a terrible idea in my opinion.

@Josh
Yes, what we have now is better than nothing. However, breaking lines manually with either "_" or "\" would have been a far superior option.
Then again, I don't care much personally. I don't remember the last PB program I wrote that was longer than 100 lines.

_________________

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

Top

 Post subject: Re: Improved line continuationPosted: Thu Dec 14, 2017 8:35 pm

Joined: Sat Jun 30, 2007 8:04 pm
Posts: 3116
Josh wrote:
I don't understand why an already exhausted thread based on insufficient hardware has to be kept alive with even more stupid suggestions like a semicolon as line-continuation.

It has nothing to do with hardware. The picture was an example.

Line continuation is a tool to for restructuring code to improve clarity. I want it because it will make my code easier to read for myself and allow me to lay it out in a clearer, more concise way, that will allow it to be more easily understood by others.

PureBasic is a very verbose language and would benefit tremendously for this feature.

On a side note, I do not care for the use of "_" as a line continuation character because at a glance it is difficult to differentiate from "-". I tried it in a few tests and my poor eyesight struggles with it.

_________________

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 2 of 2 [ 30 posts ] Go to page Previous  1, 2

 All times are UTC + 1 hour

#### Who is online

Users browsing this forum: No registered users and 7 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

Search for:
 Jump to:  Select a forum ------------------ PureBasic    Coding Questions    Game Programming    3D Programming    Assembly Programming    The PureBasic Editor    The PureBasic Form Designer    General Discussion    Feature Requests and Wishlists    Tricks 'n' Tips Bug Reports    Bugs - Windows    Bugs - Linux    Bugs - Mac OSX    Bugs - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite