DIP16: Transparently substitute module with package

deadalnix deadalnix at gmail.com
Thu Apr 5 02:47:41 PDT 2012


Le 05/04/2012 02:55, Martin Nowak a écrit :
>> What happen if both pkg.d and pkg/_.d exists ? If it is not in the
>> same path (think -I compiler option). In one case, this is an issue,
>> in the other this isn't.
> pkg.d would always be a module, hence result in a module/package conflict.
> We'd need to directly search for a subdirectory to decide whether it's a
> package.
>

This is true, but why would it be a conflict ?

Package already is a tree structure, so it shouldn't cause much trouble.

> Maybe someone with experience of big Python projects has some valuable
> insights, but I think one point of adding the file inside a folder is to
> prevent from unintended pickup of folders.

Using eponymous trick, you'd always pick up a file, never a folder. 
Hence, lookup rules get easier. Plus it is D-ish.

I have no doubt that this approach is working in python, and could work 
in D. This is exactly why this was my first proposal. But this doesn't 
means that we can't do better. I have tested quite a lot of way to 
achieve that, in several languages, and this is usually a messy topic, 
with no single solution.


More information about the Digitalmars-d mailing list