A simple rule

downs default_357-line at yahoo.de
Thu Jul 30 12:57:33 PDT 2009


In this post, I present a simple rule of thumb that covers most cases of the common decision: should a feature go in the compiler, or in the standard library?

Note: this only applies to features that aren't in C.

1) If it's a word, put it in the standard library.
2) Otherwise, put it in the compiler.

For example:

assert() -> library.
complex -> library.
void -> C-derived, compiler.
real -> C-derived via long float, compiler.
cfloat -> library.
for -> compiler.
foreach -> library.
T[] -> compiler.
T.dup, T.sort, T.reverse -> library.

I would consider this change more important than all the multithreading improvements made in D2 to date, _maybe_ more important than the const features.

The justification for this change is that words can be trivially looked up in the documentation, thus they aren't deserving of a place in the minimal working set of language features.

As it stands, the claim on the homepage that it's easier to implement a D compiler than a C++ one is highly dubious. This rule, consistently applied, would help bring back some of the simplicity that was lost during the D2.0 feature frenzy.

Your thoughts?



More information about the Digitalmars-d mailing list