Minimizing "reserved" words

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 1 03:40:06 PDT 2016


On Tuesday, November 01, 2016 08:29:17 Jacob Carlborg via Digitalmars-d 
wrote:
> On 2016-10-31 23:25, Jonathan M Davis via Digitalmars-d wrote:
> > IMHO, it's just plain error-prone to allow for any of the built-in
> > properties to be overridden, and it should be disallowed in all cases.
> > We
> > need to be able to rely on stuff like .init of .sizeof being the
> > built-in
> > property, or you're just going to get bugs - especially in generic code.
>
> That might be the case. But why are they built-in properties from the
> beginning. Compiler recognized free functions or __traits would not have
> this problem.

In general, I don't think that it would make sense for them to be functions,
and they'd be uglier as traits. And for the most part, they aren't names
that anyone is really going to want to use for their own code anyway
(particularly with the typical D naming conventions). AFAIK, the only one
that's sometimes getting defined and causing problems is init, and that's
certainly used often enough that needing something like __traits to use it
would be rather annoying. But it's certainly true that they could have have
been implemented differently originally. However, it would break far too
much code at this point to change them even if we all agreed that the
current situation was less than ideal.

But the only built-in properties that I can think of which definitely
shouldn't have been built-in proprties are the ones specific to arrays such
as sort, and they've already been deprecated in favor of proper functions.
So, the ones that were obviously a bad idea have already been taken care of.

- Jonathan M Davis



More information about the Digitalmars-d mailing list