Pseudo namespaces

tcak via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 4 13:15:40 PST 2015


On Friday, 4 December 2015 at 20:58:02 UTC, tcak wrote:
> On Friday, 4 December 2015 at 09:30:08 UTC, Walter Bright wrote:
>> On 12/4/2015 12:48 AM, Dicebot wrote:
>>> [...]
>>
>> I don't understand your comment that modules are broken. With 
>> imports, you can use the module name as a prefix or not.
>
> The problem with using modules at this point is, as I come to 
> same
> conclusion, that it forces name repetitions. Example I am 
> defining
> many APIs right now for database operations. File is over 
> thousand
> of lines, and each API is used for separate operations. I can 
> create
> a separate module for each API to decrease complexity, but than
> both the name of module and name of API function are almost same
> thing. And, as it is very clearly seen in Phobos as well, many
> names are repeated again and again which creates ugly code. I 
> even
> cannot propose any solution to this other then following the 
> long
> way: using package.d to alias same function in both module and 
> package
> which feels hackish.
>
> Andrei is, I guess, following that approach to prevent this as 
> well.

Another solution of mine was to allow giving same name to multiple
module files. So, compile would merge them as they are single. 
This
would very easily solve the most name repetition problems. (There 
is
a security risk here as overriding is possible, but I ignore it 
for now).


More information about the Digitalmars-d mailing list