When Is It Necessary to Use the Flag -Stdlib=Libstdc++

Is using flags very often in code advisable?

This:

if (condition1)
var1= true;
else
var1 = false;

Is a classic badly written code.

Instead you should write:

var1 = condition1;

And yes, flags are very useful for making the code be more readable and possibly, faster.

Can command line flags in Go be set to mandatory?

The flag package does not support mandatory or required flags (meaning the flag must be specified explicitly).

What you can do is use sensible default values for (all) flags. And if a flag is something like there is no sensible default, check the value at the start of your application and halt with an error message. You should do flag value validation anyway (not just for required flags), so this shouldn't mean any (big) overhead, and this is a good practice in general.

Why do you have to use both a compiler flag and a run-time flag to get multicore-support in Haskell?

While you're developing the program the extra +RTS ... shouldn't be a big deal (though I admit it struck me as odd when I first picked up Haskell). For the final (shipped) binary you can link it with static RTS options (GHC manual) by providing a C file containing char *ghc_rts_opts = "-N";.

EDIT: Updating this question for GHC 7.x, there is now a way to specify RTS options at compile time:

ghc -threaded -rtsopts -with-rtsopts=-N

This 1) uses the threaded runtime system 2) Enables the RTS options 3) Sets the RTS option to use as many threads as there are cores available (use -Nx where x is a number to manually control the number of OS threads).

Why do we need to use the uninsneveruninstall flag when skinning a Inno Setup Uninstaller?

It's a DLL. It's loaded into the uninstaller. So the uninstaller cannot delete it. So the flag is there, to avoid the uninstaller from failing when pointlessly trying to delete the file.

For a better solution, see the second part of my answer to:

Load external DLL for uninstall process in Inno Setup

Should flags only be binary?

Flags are usually binary because when we say flag it means either it is up(1) or down(0).
Just like it is used in military to flag up and down in order to show the war-signs. The concept of flagging is taken from there.

Regarding what you are saying

"your words : values be required (e.g. 0,1,2,3,4)"

In such a situation use Enum. Enumerations are build for such cases or sometimes what we do is , we justify the meaning of these numeric values in comments or in separate file so that more memory could be saved(we use tinyInt or bit field). But never name such a situation Flag.

Flags have standard meaning that is either Up or Down. It doesn't mean that you will get error or something but it is not a good practice. Hope you get it.

What Does the [Flags] Attribute Really Do?

From an MSDN article:

It is interesting to note that when
Flags is specified, Parse and Format
methods feature advanced capabilities.

Likewise, the Parse method can
successfully parse a comma-separated
string like the one just shown into
the proper numeric value.



Related Topics



Leave a reply



Submit