Instead of writing const, constexpr, inline, etc, could we have every method and variable automatically default to the smallest, fastest, or most constant version? And have every variable and member automatically default to the fastest type? For a few examples:
(using whiteboard)
//variable pie becomes a constant float and a constant double
pie = 3.1415926536
// compiler selects float or double, attempts to **_constexpr_** this equation, area gets the same type as myRadius
area = myRadius * pie
struct dog: //defaults to a 4-byte union unless multiple members are read later in the program
name = 'Max' //const string
numLegs = 4, numTails = 1, numIQ // const uint_fast8_t, numIQ defaults to 0
bark(): //methods are actually global functions, but can only be called within the program by an object of type 'dog'
print "ruff" //bark() defaults to an **_inline, pure_** function; print is not pure
numIQ-- //if 0, numIQ bottoms out at 0, operation attempts to **_constexpr_**
dog* Max // unique pointer of 16, 24, or 32 bits is created; Maxx will automagically be deleted
(dogGetsHit) ? Max.numLegs--
Max.bark()
In C/C++, we almost always have to sprinkle our code with keywords that let the compiler perform additional optimizations. Shouldn't the default always be to the fast way so that unprofiled code runs a bit faster, pollutes the Branch History Table and cache less, and the code and data would be a bit more compact?
Instead of writing const, constexpr, inline, etc, could we have every method and variable automatically default to the smallest, fastest, or most constant version? And have every variable and member automatically default to the fastest type? For a few examples:
(using whiteboard)
In C/C++, we almost always have to sprinkle our code with keywords that let the compiler perform additional optimizations. Shouldn't the default always be to the fast way so that unprofiled code runs a bit faster, pollutes the Branch History Table and cache less, and the code and data would be a bit more compact?