FLTK native in 'D'. Would that be useful?

Dave Dave_member at pathlink.com
Thu Jul 27 15:42:41 PDT 2006


MatthiasM wrote:
> Dave wrote:
>> I just happened to notice that there are no private class members in 
>> window.d (for example) and looking at the original window.h there 
>> probably should be.
> 
> Ouch, I did not know that. Evil little details. Yes, we assume that the 
> first members without a modifier are private.
> 
> I did find two or three "friend" declarations in the source. Is there 
> some equivalent in "D" or a good way to replace it?

D's idea of 'friend'-ship for aggregate type members is if they are in 
the same physical module (source file), or with "package" access they 
can be in the same 'package'.

'private' means private to the module. 'package' means private to the 
package. private or package member functions are never virtually 
overridden (protected or public are by default though - no need for 
'virtual').

I think 'package' would work better from what I've seen of friend being 
used in FL.

For example:

// member of "gui.fl" package
// must be specified to allow package access
module gui.fl.window;

import gui.fl.widget;

class window
{
package: // allow other modules in gui.fl to access 'window_i'
     int window_i;
private:
     widget w;
public:
     void foo()
     {
         w.widget_i = 10; // legal access to 'window_i'
     }
}

// member of "gui.fl" package
// must be specified to allow package access
module gui.fl.widget;

import gui.fl.window;

class widget
{
package: // allow other modules in gui.fl to access 'window_i'
     int widget_i;
private:
     window w;
public:
     void foo()
     {
         w.window_i = 10; // legal access to 'window_i'
     }
}

Make sense?



More information about the Digitalmars-d-dwt mailing list