Allow splitting function lines before the paremeter list

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

Allow splitting function lines before the paremeter list

Post by Mistrel »

I'm not sure when we got this feature but I just now realized that we can split lines up like this:

Code: Select all

Debug 1 +
  2 + 3
Then I thought I would finally get to split up my function declarations and definitions like so:

Code: Select all

declare
  func(
    something_a,
    something_b,
    something_c
)

Procedure
  func(
    something_a,
    something_b,
    something_c
)
  
EndProcedure
But I can't do this without putting at least one parameter on the first line. Which makes this ugly.

I know that the purpose was probably to split the line somewhere after a comma but I would prefer the option to format my declarations as described.
Last edited by Mistrel on Thu Jun 07, 2018 5:17 pm, edited 2 times in total.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Allow splitting function lines before the paremeter list

Post by Mistrel »

Line splitting as it is currently is great at helping to keep lines under 80 characters but I would still like to see greater flexibility. In its current form it lends itself to being ugly and difficult to read.

For example, I have to currently do this to keep my function under 80 characters:

Code: Select all

Procedure.POINTER BitSet_Create(_IN Length.l, 
  _IN_OPT BlockSize.BITSET_BLOCKSIZE=#BitSet_BlockSize_Byte,
  _IN_OPT ByteOrder.BITSET_BYTEORDER=#BitSet_ByteOrder_LittleEndian)
Whereas I want to do this which is much more readable:

Code: Select all

Procedure.POINTER 
  BitSet_Create(
    _IN     Length.l, 
    _IN_OPT BlockSize.BITSET_BLOCKSIZE=#BitSet_BlockSize_Byte,
    _IN_OPT ByteOrder.BITSET_BYTEORDER=#BitSet_ByteOrder_LittleEndian
)
The same goes for operators. It's frustrating to have to scan over the entire line to see if there is a trailing operator. I would much rather scan vertically along the first character of my indent blocks which would all be lined up and easy to see.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Allow splitting function lines before the paremeter list

Post by Mistrel »

Just had a line like this with a floating variable and it looks so weird:

Code: Select all

String.s=SomeReallyLongLine.s+
  String.s
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Allow splitting function lines before the paremeter list

Post by Mistrel »

I would still really love to see this at some point.
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Allow splitting function lines before the paremeter list

Post by NicTheQuick »

+1
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Allow splitting function lines before the paremeter list

Post by Trond »

Mistrel wrote:Just had a line like this with a floating variable and it looks so weird:

Code: Select all

String.s=SomeReallyLongLine.s+
  String.s
I would have written it like this:

Code: Select all

String.s = SomeReallyLongLine.s + 
           String.s
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Allow splitting function lines before the paremeter list

Post by NicTheQuick »

I would like to write it this way

Code: Select all

String.s = SomeReallyLongLine
         + String
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: Allow splitting function lines before the paremeter list

Post by Marc56us »

String.s = SomeReallyLongLine
+ String
This is not possible (IMHO) because the precompiler would have to read the following line each time (not to think that it is a typo error)

In my opinion, it would be easier for the team to implement the classic basic line continuation character

https://docs.microsoft.com/en-us/dotnet ... ts-in-code

"To break a single statement into multiple lines
Use the line-continuation character, which is an underscore (_), at the point at which you want the line to break. The underscore must be immediately preceded by a space and immediately followed by a line terminator (carriage return).
"

PS. Some other languages and script uses \ instead of _
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Allow splitting function lines before the paremeter list

Post by Dude »

Marc56us wrote:In my opinion, it would be easier for the team to implement the classic basic line continuation character
That's been discussed many times before and the decision was made not to do it. Sad, I know. :(
User avatar
blueb
Addict
Addict
Posts: 1041
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Allow splitting function lines before the paremeter list

Post by blueb »

Al_the_dutch's suggestion makes the most sense:

see: viewtopic.php?p=515024#p515024
- It was too lonely at the top.

System : PB 6.10 Beta 9 (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: Allow splitting function lines before the paremeter list

Post by Marc56us »

Yes,
however, I think it is more logical and shorter to use the classic syntax of all basic languages (VBS, VB, VBA): _
(space + underscore)

This character also has the advantage that it has no PB meaning, unlike '\' which is used for structures.
so no need to add directives like "Enable LineContinuation"

:idea: :?: :wink:
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Allow splitting function lines before the paremeter list

Post by Trond »

Marc56us wrote:This character also has the advantage that it has no PB meaning, unlike '\' which is used for structures.
Underline is a legal variable name in PB, so that isn't going to work.
Post Reply