- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
protected[qual] members have their name mangled
Sat, 2010-04-03, 19:46
Hello.
I just noticed that "protected[qual]" symbols have their names mangled, like private symbols.
Other protected symbols keep their original names.
Is this intended, and if so, why?
Cheers,
Gilles.
Sat, 2010-04-03, 21:57
#2
Re: protected[qual] members have their name mangled
>> I just noticed that "protected[qual]" symbols have their names mangled, like private symbols.
>>
>> Other protected symbols keep their original names.
>>
>> Is this intended, and if so, why?
>
> I'm pretty sure it is intended, but I'd have to dig a bit why. AFAIK it was Sean who was demanding that.
I see. I usually assume that a behaviour I do not understand is intended. But in that case, it really seemed suspicious to me.
Firstly, protected[this], which restricts access more, is not name mangled.
Secondly, I find the design of how protected[qual] is encoded in symbols to be error prone. It seems natural to write a test to check if a symbol is private like this:
(sym.isPrivate) || (privateWithin != NoSymbol)
But this is wrong because privateWithin is actually also used for protected symbols. Strangely, for protected symbols, flag PROTECTED is set in addition to setting privateWithin, but for private symbols, privateWithin is set without a PRIVATE flag. Therefore, a correct test is something like:
(sym.isPrivate) || !((sym.isProtected) || (privateWithin == NoSymbol))
Maybe this clarifies why I asked this question. It's not urgent or anything; I was just checking.
Good night,
Gilles.
On Sat, Apr 3, 2010 at 8:46 PM, Gilles Dubochet <gilles.dubochet@epfl.ch> wrote:
I'm pretty sure it is intended, but I'd have to dig a bit why. AFAIK it was Sean who was demanding that.
Cheers
-- Martin