Ky -
Ky -

Reputation: 32083

Are there consequences to #define this self?

Long has Objective C annoyed me with its decision to use self instead of this. Now, I want to end that frustration by placing this code somewhere at or near the start of my program:

#define this self

I know this will compile, and likely will work as I expect. However, I can't help but think there are... unforeseen consequences to this. Is this a safe thing to do, or are there problems that will arise outside the simple problem I'm trying to solve?

Upvotes: 0

Views: 62

Answers (2)

newacct
newacct

Reputation: 122429

Another consequence is that, if imported into C++ or Objective-C++ code, it could break code that uses this by turning it into self which would then be an undefined variable.

Upvotes: 2

qwerty_so
qwerty_so

Reputation: 36295

The consequence will likely be that no-one else but you can read your code and will get confused by your own convention here.

Upvotes: 6

Related Questions