Minimizing "reserved" words

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Mon Oct 31 15:25:40 PDT 2016


On Monday, October 31, 2016 22:22:00 Jacob Carlborg via Digitalmars-d wrote:
> On 2016-10-31 21:53, Steven Schveighoffer wrote:
> > The plan is to deprecate .init as an overridable method or field, and
> > then remove support (i.e. .init ALWAYS refers to the compile-generated
> > init instance). First step is for Phobos/druntime to eradicate all uses
> > of it.
>
> I suspected this was the plan. My post was about that there are other
> built-in properties that have the same problem. Also that the solution,
> to not make them overridable, might not be the best solution. The
> current implementation (built-in properties) don't add much advantage
> but has the disadvantage of taking up an additional word as reserved.

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.

I see no problem with being able to declare a variable with any of those
names, and it's probably okay for them to be used as the names of free
functions (and if you tried to use UFCS with them, they'd even be acting the
way that UFCS normally acts in the cases where there's a conflict). It's
just that they shouldn't be allowed to be declared as members of a type,
because they're already there with the built-in properties. Honestly, it
seems like a pretty serious bug to me that it's ever been possible to
declare any of them as members.

- Jonathan M Davis



More information about the Digitalmars-d mailing list