If I could have a language of my own, it would be like C++ but with some changes:
-No pointers; they would not be needed. You could simply use the value of any integral variable as the address and then the type to get it as.
-The integer data type would be the only type that allows you to specify the number of bytes to use, eg
signed int@16 My128BitSignedInteger;
-You could define many functions in a loop with the name conataining having the values of strings or numbers, eg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
for(unsigned long i = 0; i < 20; ++i)
{
//the "rapidfunc" keyword indicates that the function is created on the fly,
//and that it uses variable values as macros.
rapidfunc signed long Func#i#Named$SomeString$(signed long A, signed long B)
{
return(A * #i# * B);
}
}
//later...
//the "callrapidfunc" keyword indicates again that variables' values may be used in
//function call. The (0) is the value to return if the function does not exist.
int x = callrapidfunc(0) Func1NamedHello(2, 4);
x = callrapidfunc(x) Func#x#NamedBye(x, 2 * x);
|
-Switch and Case statements would be able to optionally accept non-constants if you use this alternative syntax:
1 2 3 4 5 6 7 8 9 10 11
|
switch(SomeVar)
{
case(AnotherVar) //() for non-constants, and
{ //{} if you don't want to have to include a break statement
DoStuff();
}
case($$ >= AlwaysVar) //$$ indicates that value that was passed to the switch statement (in this code, SomeVar)
{ //with this method you can use the case statement like an if statement
DoOtherStuff();
}
}
|
-Of course, you could be allowed to pass a parameter to break for the number of control structures to break out of, eg
break(2);
which would essentially be the default of just
break;
-Functions can have optional parameters without the rest after them having to be optional as well:
1 2 3 4 5 6 7 8
|
long MyFunc(long A, long B = 4, long C, long D = -2)
{
return(A * ((B - C) / (A * (B - C))) + D);
}
//later...
MyFunc(4, ~, 5); //the ~ operator, in this case, means 'use the default value for this parameter'
|
-Operator !| which essentially does this:
1 2 3 4 5
|
//operator !| function equiv:
bool NotOr(bool A, bool B)
{
return((A || B) && !(A && B));
}
|
As you can see it's a bit crazy, but it'd make some stuff simpler. I can't really think of much else to fix or add...