Forums

implict access modifier protected on _named Box Items

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

implict access modifier protected on _named Box Items

Postby hopscc » Tue Sep 09, 2008 1:29 am

Its documented somewhere that class vars named with a leading '_' are implicitly made protected
- this is really convenient
Code: Select all
class X
    var _x =0
    var y = 1

generates c# code like

#line 3
        protected Int32 _x = 0;
#line 4
        public Int32 Y = 0;


However methods and properties named the same way are not - I'm wondering if this is by design or just fell out of
the earlier policy of forcing all class vars to be _named

Code: Select all
class Y
    get  _x
        return 99

    def _isProt
        pass

gens c# code like

        public virtual  /*dynamic*/object _x {
#line 6
                get{
#line 7
                        return 99;
#line 7
                }
#line 13
        public virtual void _isProt() {
#line 14
        }

I think it would be equally convenient ( and nicely symmetric) if naming properties and methods in this manner also generated them as (implicitly) protected

'__' ( double underscore prefixed) names (for vars and methods) implicitly private ???
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: implict access modifier protected on _named Box Items

Postby Charles » Wed Sep 10, 2008 2:37 pm

This surprised me -- my intent was that _foo members were protected regardless of what kind of member they were (var, def, pro). So I consider it a bug that "def _foo" is public.

Also, I agree that __ should be private. This matches Python and I can't think of any drawbacks.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: implict access modifier protected on _named Box Items

Postby Charles » Thu Sep 11, 2008 1:10 am

Fixed in development. Nice catch.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 103 guests

cron