Does the 'package' protection attribute not work?

Michel Fortin michel.fortin at michelf.com
Mon Aug 8 19:59:30 PDT 2011


On 2011-08-08 13:55:32 +0000, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> On 8/8/11 1:56 AM, Jacob Carlborg wrote:
>> On 2011-08-08 00:29, Robert Clipsham wrote:
>>> On 07/08/2011 22:18, Jonathan M Davis wrote:
>>>> Personally, I don't see much point in using the package specifier when
>>>> you're
>>>> not actually using a package hierarchy (you're just making it so that
>>>> everything but stuff which actually uses a hierarchy can use the
>>>> function - it
>>>> would be a really weird distinction to make). So, it wouldn't entirely
>>>> surprise me if this is completely by design. It might be a bug though.
>>> 
>>> Except package is ~100% useless if you use an *actual* package
>>> hierarchy[1][2][3] (not like phobos which just drops everything in a
>>> top-level package).
>>> 
>>>> 
>>>> - Jonathan M Davis
>>> 
>>> [1] http://d.puremagic.com/issues/show_bug.cgi?id=143
>>> [2] http://d.puremagic.com/issues/show_bug.cgi?id=2529
>>> [3] http://d.puremagic.com/issues/buglist.cgi?quicksearch=package
>>> 
>>> 
>> 
>> In addition to that a method declared as "package" won't be virtual.
> 
> Ouch. Why is that? Seems like a bug.

Seems by design. See dmd/src/func.c :

	int FuncDeclaration::isVirtual()
	{
	#if 0
	    …
	#endif
	    Dsymbol *p = toParent();
	    return isMember() &&
	        !(isStatic() || protection == PROTprivate || protection == 
PROTpackage) &&
	        p->isClassDeclaration() &&
	        !(p->isInterfaceDeclaration() && isFinal());
	}

At least now you know where to fix this.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list