Re: [Pyobjc-dev] Underscores in methods/instance variables
Brought to you by:
ronaldoussoren
|
From: Orestis M. <or...@or...> - 2009-03-29 17:18:07
|
Let me clarify something - is this only an issue when you need to call
a method from Obj-C or is it affecting everything that inherits from
NSObject?
Orestis
On 29 Mar 2009, at 15:27, Ronald Oussoren wrote:
> That's correct. Apple reserves names starting with underscores for
> their own usage. I do sometimes use underscores in my own code, but
> that code could get broken on future versions of OSX.
>
> BTW. PyObjC code and regular python code cannot follow exactly the
> same coding conventions for other reasons as well, PEP8 style
> nameing for methods ("do_something" instead of "doSomething") causes
> problems with PyObjC's automatic deduction of the ObjC method name.
>
> Ronald
>
> On 28 Mar, 2009, at 18:32, Petr Mifek wrote:
>
>> Hi,
>>
>> I made some more digging into this matter and the only thing I
>> found so
>> far is this one (sorry, a long one):
>>
>> http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html#/
>> /apple_ref/doc/uid/20001282-1003829-BCIBDJCA
>>
>> and some good insights here:
>>
>> http://www.cocoadev.com/index.pl?CodingGuidelines
>>
>> So unless anybody knows and posts more profound answer, I suggest
>> that
>> the paragraph in the PyObjC intro stating """...instance variables
>> prefixed with underscores are reserved by the Objective-C
>> runtime..."""
>> was put there based on the Apple's recommendation of not using such
>> variables.
>>
>> Cheers,
>> Petr
>>
>> Orestis Markou wrote:
>>> Hello all,
>>>
>>> I want to clarify a bit the advice of the documentation to *not* use
>>> the Python conventions of not using leading underscores for
>>> "private"
>>> instance attributes.
>>>
>>> Is it the danger of accidentally overwriting some other Obj-C
>>> attribute if there's a name clash? What about methods with leading
>>> underscores?
>>>
>>> I fully understand that in order a method to be accessible from
>>> Obj-C
>>> code it has to follow the methodWithArg_andArg_(self, arg1, arg2)
>>> convention. In my case, these are "private" methods that I have no
>>> desire to expose to anyone.
>>>
>>> The class in question is just a delegate that implements a custom
>>> init
>>> method and the delegate method. These are the only things that use
>>> the
>>> obj-c convention. The rest of the code is using the Python
>>> convention,
>>> with leading underscores in attributes and methosd, property
>>> decorators and so on.
>>>
>>> Testing indicates that things are working perfectly fine, I'm just
>>> worried that there may some stability issues that may not visible at
>>> this point. I've heard rumours of hard crashes that may have been
>>> related to this, so I'm a bit worried.
>>>
>>> Thanks,
>>> Orestis
>>> --
>>> or...@or...
>>> http://orestis.gr/
>>>
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> Pyobjc-dev mailing list
>>> Pyo...@li...
>>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Pyobjc-dev mailing list
>> Pyo...@li...
>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
>
|