PB5.42b1 ":" in Enumerations (tiny bug)

Just starting out? Need help? Post your questions and find answers here.
User avatar
Regenduft
Enthusiast
Enthusiast
Posts: 121
Joined: Mon Mar 02, 2009 9:20 pm
Location: Germany

PB5.42b1 ":" in Enumerations (tiny bug)

Post by Regenduft »

PureBasic 5.42 Beta 1 (x86/x64) on Windows 7

Using ":" as a line separator in an Enumeration will make PureBasic complain under some rare circumstances.
PureBasic wrote:Line 3: Only constants are allowed in an Enumeration.

Code: Select all

Enumeration NotWorking
  #anna
  :
  #berta
EndEnumeration


Enumeration WorksFine
  #foo
  #bar : #barossa
  #boo
EndEnumeration


Enumeration WhyImUsingIt
  
  #bla
  
  :     ; ":" makes this comment shiftable with crtl+e to make
  #bli  ; it a nice looking block comment, but doesn't work...
  
  #blub
  
EndEnumeration
I know, that this is located somewhere on the borderline between bug and feature request.
I posted this in the bug section because it is actually correct PureBasic syntax, although it's usage and the need for it may be a topic for a discussion. ;)
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: PB5.42b1 ":" in Enumerations (tiny bug)

Post by Demivec »

Regenduft wrote:Using ":" as a line separator in an Enumeration will make PureBasic complain under some rare circumstances.
Honestly I think your desire to use ':' in this manner is a bit absurd. It is used to combine two code lines into one physical line. You are using it to separate two physical lines.

In your code you write:
; ":" makes this comment shiftable with crtl+e to make
; it a nice looking block comment, but doesn't work...
If you leave out the ':' on the line by itself everything still works fine using [ctrl+e] to line things up. If you are re-indenting the lines using [ctrl+i] then you will run into problems.

If you first line things up with [ctrl+e] then add a ';' where you would of previously put the ':' it can function the same way, as long as you don't use [ctrl+e] on those lines again.

I think what you describe as your need could be done with a new 'NOP' (no operation) function to put on the line instead. It would be something that doesn't compile but holds the space and keep it aligned.

How about this?

Code: Select all

;Choose your macro name wisely ;)
Macro __
EndMacro


Enumeration WhyImUsingIt
  
  #bla
  
  __      ; ":" makes this comment shiftable with crtl+e to make
  #bli    ; it a nice looking block comment, but doesn't work...
  
  #blub
  
EndEnumeration

UndefineMacro __  ;If you only need it for enumerations it's not a bad idea to remove it afterwards.




I do think this falls in line (pun intended) with being a feature request instead of being a bug report.
User avatar
Regenduft
Enthusiast
Enthusiast
Posts: 121
Joined: Mon Mar 02, 2009 9:20 pm
Location: Germany

Re: PB5.42b1 ":" in Enumerations (tiny bug)

Post by Regenduft »

Regenduft wrote:I know, that this is located somewhere on the borderline between bug and feature request.
I posted this in the bug section because it is actually correct PureBasic syntax, although it's usage and the need for it may be a topic for a discussion. ;)
So Demivec, I mostly agree with your posting. The core statement is just that it's correct PureBasic syntax and therefore a (tiny) bug. Maybe there's a deeper problem hidden with ":" as line separator... or maybe not... who knows...

Thanks for the nice idea with the NOP macro! It's a useful way around this little problem.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: PB5.42b1 ":" in Enumerations (tiny bug)

Post by Dude »

Regenduft wrote:it's correct PureBasic syntax
Actually, it's not. As mentioned, you can't use a colon by itself on a line because you're not separating multiple commands on the same line with it, which is what the manual says it's for:
PureBasic Manual wrote:Any number of commands can be added to the same line by using the : option.
So, the way you're using it is incorrect PureBasic syntax.
Post Reply