Automatic typing
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Jul 1 19:15:03 PDT 2013
On 7/1/13 6:29 PM, JS wrote:
> Would would be nice is an experimental version of D where would could
> easily extend the language to try out such concepts to see if they truly
> are useful and how difficult to implement. e.g., I could attempt to add
> said "feature", it could be merged with the experimental compiler, those
> interested can download the compiler and test the feature out... all
> without negatively affecting D directly. If such features could be
> implemented dynamically then it would probably be pretty powerful.
I don't think such a feature would make it in D, even if the
implementation cost was already sunken (i.e. an implementation was
already done and one pull request away).
Ascribing distinct objects to the same symbol is a very core feature
that affects and is affected by everything else. We'd design a lot of D
differently if that particular feature were desired, and now the
fundamentals of the design are long frozen. For a very simple example,
consider:
auto a = 2.5; // fine, a is double
...
a = 3;
By the proposed rule a will become an entirely different variable of
type int, and the previous double variable would disappear. But current
rules dictate that the type stays double. So we'd either have an
unthinkably massive breakage, or we'd patch the language with a million
exceptions.
Even so! If the feature were bringing amazing power, there may still be
a case in its favor. But fundamentally it doesn't bring anything new -
it's just alpha renaming; it doesn't enable doing anything that couldn't
be done without it.
Andrei
More information about the Digitalmars-d
mailing list