Time to destroy Walter: breaking modules into packages
Max Samukha
maxsamukha at gmail.com
Thu Jun 6 01:58:06 PDT 2013
On Thursday, 6 June 2013 at 06:26:17 UTC, Jonathan M Davis wrote:
> On Thursday, June 06, 2013 08:09:38 Max Samukha wrote:
>> On Thursday, 6 June 2013 at 02:36:12 UTC, Jonathan M Davis
>> wrote:
>> > But I believe that package level access only works on the
>> > same
>> > level, so you
>> > couldn't have separate modules for compressing and
>> > decompressing as was being
>> > suggested.
>>
>> 'package' should be fixed so that 'package' declarations are
>> accessible within nested packages.
>
> Well, it _is_ debatable as to whether that's desirable or not.
> With the
> current behavior, you can have a package which shares stuff
> within itself but
> not with its sub-packages, but there's no way to share with the
> sub-packages
> without making the symbols public; whereas if sub-packages have
> access to
> their parent packages' package functions, then packages _can_
> share with their
> sub-packages, but they can't restrict anything to just the
> package. Both ways
> have their pros and cons. I don't know which is ultimately
> better.
There is not much to debate. Get your hands dirty with a real
project having more than two levels of packages and you'll see
that the first is ultimately better.
While limiting 'package' to one level may be sometimes desirable,
forcing package-private members to be world-public is highly
undesirable. As a package author I can tolerate loose access
policies within a package tree that *I* control but I definitely
don't want to expose to the user of my package what he shouldn't
have access to.
More information about the Digitalmars-d
mailing list