www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - 'package'

reply Manu via Digitalmars-d <digitalmars-d puremagic.com> writes:
I'm having all sorts of visibility problems.
I have this:

  app/system/...
  app/system/widgets/...

The 'system'/manager should be able to access all the widgets internals,
but things outside the system shouldn't be able to touch the internals.
This is what 'package' is supposed to be for, except 'package' in widgets
only allows access to other widgets, 'system' level modules have no
access...

Is there a workaround for this case? I'm not sure what to do.

I guess the trouble is that 'package' specifies sibling modules and below,
but nothing above... but this isn't always the module structure.
I'm thinking 'package' needs to know the top level that can access
internals. Perhaps this would solve my problem elegantly:

  module app.system.widgets.widget;  // <- module is beneath 'widgets'

  package(app.system):
  ...  internal stuff that 'app.system' (ie, the 'package') and below can
access ...

Or is there an existing solution that I can't find?
Jul 21 2014
parent reply "Dicebot" <public dicebot.lv> writes:
On Monday, 21 July 2014 at 17:32:53 UTC, Manu via Digitalmars-d 
wrote:
 I'm having all sorts of visibility problems.
 I have this:

   app/system/...
   app/system/widgets/...

 The 'system'/manager should be able to access all the widgets 
 internals,
 but things outside the system shouldn't be able to touch the 
 internals.
 This is what 'package' is supposed to be for, except 'package' 
 in widgets
 only allows access to other widgets, 'system' level modules 
 have no
 access...

 Is there a workaround for this case? I'm not sure what to do.

 I guess the trouble is that 'package' specifies sibling modules 
 and below,
 but nothing above... but this isn't always the module structure.
 I'm thinking 'package' needs to know the top level that can 
 access
 internals. Perhaps this would solve my problem elegantly:

   module app.system.widgets.widget;  // <- module is beneath 
 'widgets'

   package(app.system):
   ...  internal stuff that 'app.system' (ie, the 'package') and 
 below can
 access ...

 Or is there an existing solution that I can't find?
https://github.com/D-Programming-Language/dmd/pull/3651
Jul 21 2014
parent Manu via Digitalmars-d <digitalmars-d puremagic.com> writes:
Awesome!
Here's hoping for swift inclusion! :)


On 22 July 2014 03:43, Dicebot via Digitalmars-d <
digitalmars-d puremagic.com> wrote:

 On Monday, 21 July 2014 at 17:32:53 UTC, Manu via Digitalmars-d wrote:

 I'm having all sorts of visibility problems.
 I have this:

   app/system/...
   app/system/widgets/...

 The 'system'/manager should be able to access all the widgets internals,
 but things outside the system shouldn't be able to touch the internals.
 This is what 'package' is supposed to be for, except 'package' in widgets
 only allows access to other widgets, 'system' level modules have no
 access...

 Is there a workaround for this case? I'm not sure what to do.

 I guess the trouble is that 'package' specifies sibling modules and below,
 but nothing above... but this isn't always the module structure.
 I'm thinking 'package' needs to know the top level that can access
 internals. Perhaps this would solve my problem elegantly:

   module app.system.widgets.widget;  // <- module is beneath 'widgets'

   package(app.system):
   ...  internal stuff that 'app.system' (ie, the 'package') and below can
 access ...

 Or is there an existing solution that I can't find?
https://github.com/D-Programming-Language/dmd/pull/3651
Jul 21 2014