I've been thinking about doing my own language (practicality: it's a thought experiment). One of the ideas I came up with is in-language semantic variation. You'd write essentially semantic regular expressions, to be replaced with equivalent code. You can see this in a somewhat less direct form in D- they have string mixins that convert to D code. Except I was going to do them implicitly, and in a more circular fashion.
Right now, I originate from C++. So if you consider:
string a, b, c, d;
// do stuff
a = b + c + d;
This code results in various temporaries. Even if you have rvalue references, you will create temporaries, they will simply be re-used more efficiently. But they still exist and still waste performance. I was thinking about, in the most simple case, of how these could be eliminated. You could write a semantic regular expression that would convert it into the most optimized form.
string a, b, c, d;
// do stuff
a.resize(b.size() + c.size() + d.size());
a = b; a += c; a += d;
If I implemented std::string, I might be able to write something even faster. The key to this is that they're implicit - when you use the std::string class, the axioms written by the std::string implementer can affect any std::string code. You could just drop it in to an existing C++ codebase, recompile, and get the fastest string concatenation that your std::string implementer can conceive of for free.
At the moment, the optimizations you can make are limited, because you only have as much context as the language allows you, in this case, operator overloading in C++ only taking two arguments, this and arg. But a semantic reg ex could take virtually all the context you could ever need - since you can dictate what it matches - and even match to language features that don't exist in the host language. For example, it would be trivial to exchange
string a;
a.size;
for
string a;
a.size();
if you wanted to steal C# properties. You could match class definitions and implement compile or run time reflection, etc.
But, I mean, it could get confusing. If there was a bug, or what was really done behind the scenes didn't reflect the code that was written, it could be a total bitch to track down, and I've not considered how it would be implemented in depth. What do you guys think of my proposed language feature?
Oh man, choosing the right tags. Ummm....
Edit: I also wanted to breach the scope of limits, as regards to one answer I had. The simple fact is that semantic regex has no limits (minus implementation details that may have to be added). For example, you could turn the expression
int i;
cin >> i;
int lols[i];
into
int i;
cin >> i;
std::variable_array<int>(alloca(sizeof(int) * i), i);
The semantics of alloca make manipulation with templates impossible- you have to write a macro if you want the above. In C++03 or C++0x, you cannot encapsulate your own VLAs.
In addition, semantic regexes can match code that doesn't actually invoke any compile-time work. For example, you could match every member of a class definition and use it to create a reflection system. This is also impossible in C++ to date.