www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - RFC: Deprecating the Module Operator

reply %u <unknown dontsay.com> writes:
The current module operator, the ".", seems to be a bad choice,
because it is easily overseen and in conjunction with an accidentically
deleted character may result in bugs, that are hard to discover:
  var= o1*.o2;
vs.
  var= o1..o2;
vs.
  var=.o1.o2;
...

Moreover the module operator just seems to be syntax sugar, because
one needs not to write the name of the module.

OTOH if there is a need not to write the module name, then the well
known and more general file hierarchy navigation notation should be
used, where "//" denotes the root and "../" denotes direct ancestors.
--
Anonymity is not a Crime
Jan 19 2007
parent Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
%u wrote:
 The current module operator, the ".", seems to be a bad choice,

I presume you mean the prefix-'.', not the binary-'.' "member-of" operator.
 because it is easily overseen and in conjunction with an accidentically
 deleted character may result in bugs, that are hard to discover:
   var= o1*.o2;
 vs.
   var= o1..o2;
 vs.
   var=.o1.o2;

When is the first variant valid syntax? I'm pretty sure the second one will also never be valid syntax. At least, not for D 1.0. The only potential conflict like 2 vs 3 that I can see will be inside array brackets[1], i.e. "arr[o1..o2]" vs "arr[.o1.o2]". And I expect that will be easily distinguished by the resulting compile error on the one that doesn't make sense for the type of symbol o1 is... [1]: Not necessarily on an array, due to operator overloading, but you know what I mean.
 Moreover the module operator just seems to be syntax sugar, because
 one needs not to write the name of the module.

You do need to if there's otherwise a name conflict. (Though that can also be resolved by alias usage, it's sometimes cleaner to just use the full name)
 OTOH if there is a need not to write the module name, then the well
 known and more general file hierarchy navigation notation should be
 used, where "//" denotes the root and "../" denotes direct ancestors.

Please not. I have no words for this. So I'll take this quote about D from "Jeff M": "It's like C++ except that it doesn't make me want to shove knitting needles into my eyes." and just add this: let's keep it that way :P. Luckily '//' is used for line comments in D so it's not going to happen.
 --
 Anonymity is not a Crime

In a public forum though, pseudonymity is generally preferred. That way you can at least tell people apart ;).
Jan 19 2007