Make the "Create threadsafe executable" enabled by default

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
codeprof
User
User
Posts: 65
Joined: Sun Sep 16, 2012 12:13 pm

Make the "Create threadsafe executable" enabled by default

Post by codeprof »

I think for beginners speed is not so much important. It is much more important that the application runs correctly.
E.g. If somebody just tests the sample code for "CreateMutex()" it will crash directly.

Also I do not think this breaks to much existing code... (existing code would also only be affected if it is copied newly into the editor)
Otherwise there should be at least a hint in the comment at the beginning of the sample code.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Make the "Create threadsafe executable" enabled by defau

Post by luis »

I think the default settings should be the most light ones and every "addition" should be explicitly selected.
No debugger, no thread safe, no unicode, no purifier, etc., you can set the defaults you like more in compiler option.

New users can learn reading the helpfile like I did when I started or make obnoxious questions here in the forum :)

If a demo in the help file really need the thread safe option I think it would be better to add this to the code:

Code: Select all

CompilerIf (#PB_Compiler_Thread = 0)
   CompilerError "Please enable THREADSAFE in the compiler options"
CompilerEndIf
The delicate equilibrium of the new user is protected and we are all happy.
"Have you tried turning it off and on again ?"
A little PureBasic review
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Make the "Create threadsafe executable" enabled by defau

Post by MachineCode »

As I requested once before, the compiler should just enable thread safety if "CreateThread()" is used in the source, and disable it if not. Smart compiling.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
Demivec
Addict
Addict
Posts: 4257
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Make the "Create threadsafe executable" enabled by defau

Post by Demivec »

MachineCode wrote:As I requested once before, the compiler should just enable thread safety if "CreateThread()" is used in the source, and disable it if not. Smart compiling.
Smart compiling requires more than one pass for the compiler since the mode of compiling has to be known before it is started.

You do not necessarily need or require thread safety when using CreateThread(). It is true that it is needed in many or most situations but it isn't needed for all of them.

I agree with luis that it is an option that should require selection.

I would be in favor of a way to set compiling options at the top of the code though (i.e. Compile_ThreadSafe, Compile_ASCII, Compile_Unicode, etc.). This would allow placing these options in code without having to put multiple checks with CompilerIf to see if the needed settings are in place. Even so, this would still require a standard set of options when nothing is specified; that's what we already have. :)
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Make the "Create threadsafe executable" enabled by defau

Post by skywalk »

+1 to enable compiler functions in the code.
Then I can drop the comments telling me what to enable and the checks if I didn't. :oops:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Post Reply