Debug [DebugLevel, ] <expression>

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Captn. Jinguji
User
User
Posts: 91
Joined: Sun Oct 24, 2004 9:25 am

Debug [DebugLevel, ] <expression>

Post by Captn. Jinguji »

Could we have the debug statement like this:

Debug [DebugLevel, ] <expression>

instead of our traditional

Debug <expression> [, DebugLevel]

, please?

That way, (especially when debug statements have long, complicated expressions to contend with )
* it would look more tidy
* the debuglevel assignment of debug statements would be immediately visible, as opposed to having to scroll to the code line's end;
* it would be easier to apply [mass-] changes to the debuglevel assignment of debug statements
* it wouldn't break programs' functionalities
* if made optional by an additional statement like - say - "EnableDebugLevelFirst",
harm to existing program code using "traditional" debug lines is being prevented, if that statement is simply not issued.
(Not sure how people go about their debug lines in their code once a program is considered "finished", I usually throw the debug lines out )
Is this an artifact or should it be disposed of ?
BarryG
Addict
Addict
Posts: 1706
Joined: Thu Apr 18, 2019 8:17 am

Re: Debug [DebugLevel, ] <expression>

Post by BarryG »

Captn. Jinguji wrote: Mon Sep 20, 2021 11:10 am(Not sure how people go about their debug lines in their code once a program is considered "finished", I usually throw the debug lines out )
If the Debug statement is on its own line, then that line isn't compiled into the final executable and you don't need to do anything (or throw them out).
Captn. Jinguji
User
User
Posts: 91
Joined: Sun Oct 24, 2004 9:25 am

Re: Debug [DebugLevel, ] <expression>

Post by Captn. Jinguji »

I know that ^^

But the debug lines clutter tbe view, unnecessarily.
Is this an artifact or should it be disposed of ?
Axolotl
Enthusiast
Enthusiast
Posts: 132
Joined: Wed Dec 31, 2008 3:36 pm

Re: Debug [DebugLevel, ] <expression>

Post by Axolotl »

I wonder if this DebugLevel command is really used much.
I only use DebugLevel in Include Files. Otherwise I only comment out debug statements that are not currently needed. You never know when you will need them again.
Until it is implemented you can also achieve the desired similar result with the help of a macro:

Code: Select all

Macro MyDebug(Level, Message) 
  Debug Message, Level 
EndMacro 

But I think you know that yourself.
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 10 Home
Captn. Jinguji
User
User
Posts: 91
Joined: Sun Oct 24, 2004 9:25 am

Re: Debug [DebugLevel, ] <expression>

Post by Captn. Jinguji »

Yes, Axolotl, I do know, but thanks anyway.

I think the usefulness of debuglevel is dependant of what you do.
It may well be that many fellow programmers never use it, but keep to simple "debug <expression>" lines.
They wouldn't have to change a thing if my proposal really got implemented.

But once one gets the hang of it ...
In my case, one application, for example, is the processing of texts from YT comments (as a an easily available sample source ),
passed through many stages of filters and processors.
It is really sometimes outrageous what people do to mistreat texts in order to express how oh so creative they (believe they) are.
As the philosopher put it: NEVER assume you can curb imbecility, the idiots are way too resourceful.
Thus, b..sh.t suddenly turning up in the final output may have been (re-)induced on any given previous stage,
And then having to de-comment umpteen debug statements is not funny.
Is this an artifact or should it be disposed of ?
#NULL
Addict
Addict
Posts: 1364
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Debug [DebugLevel, ] <expression>

Post by #NULL »

This code currently currently outputs '1'

Code: Select all

#val = 1
#dl = 2
DebugLevel #dl
Debug #val, #dl
After your change it will output nothing without any error, warning or hint. It silently breaks [debugging-]code just because you like the parameters the other way around. There is no way they would even consider this.
Captn. Jinguji
User
User
Posts: 91
Joined: Sun Oct 24, 2004 9:25 am

Re: Debug [DebugLevel, ] <expression>

Post by Captn. Jinguji »

It wouldn't , but if you cannot or are unwilling or unable to read and understand more than a single line of text at a time, that's not my problem.
Is this an artifact or should it be disposed of ?
#NULL
Addict
Addict
Posts: 1364
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Debug [DebugLevel, ] <expression>

Post by #NULL »

With EnableDebugLevelFirst it wouldn't, that's right. I hope you never design a language though. It's bad if you have to look for an EnableDebugLevelFirst in all the previous code to know what a Debug statement actually does.
Post Reply