Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling a +method using [self class] is clumsy #9

Open
mulle-nat opened this issue Feb 13, 2019 · 5 comments
Open

Calling a +method using [self class] is clumsy #9

mulle-nat opened this issue Feb 13, 2019 · 5 comments

Comments

@mulle-nat
Copy link
Member

You used to be able to call isa and maybe this should become a keyword just like self (again).

@mulle-nat mulle-nat changed the title Calling the a classmethod using [self class] is clumsy Calling a +method using [self class] is clumsy Feb 13, 2019
@mulle-nat
Copy link
Member Author

To clarify:

- (void) clone
{
   id clone;
   clone = [[self class] new];
}

is lame when you could write

- (void) clone
{
   id clone;

   clone = [isa new];
}

The problem is that isa used to be a struct member, but could should be elevated to keyword status.

@hsnamr
Copy link
Member

hsnamr commented May 18, 2019

Why not call it instancetype instead of isa? More ObjC are familiar with instancetype keyword and I think it makes sense to use it in this context.

I would like to investigate this and see if I can figure it out.

@mulle-nat
Copy link
Member Author

instancetype is a compiler construct. It's not a real type. F.e. you can't do @encode( instancetype). I hope that helps 😃

@hsnamr
Copy link
Member

hsnamr commented May 18, 2019

I reviewed this repository and I am not sure where do I need to make the change to add isa as a keyword. Is the source code in this repository or another repository?

@mulle-nat
Copy link
Member Author

The general idea of the library structure is, that MulleObjC is based on mulle-objc-runtime, and does the runtime specific stuff (i.e. NSObject).

mulle-objc-compat is a layer on top of mulle-objc-runtime, to emulate and translate Apple runtime functions like object_getClass to mulle_objc_object_get_isa for instance.

Finally objc-compat contains various "stuff" to write compatible code, where the Apple Foundation and the MulleFoundation differ.

So its debatable if isa would be part of mulle-objc-compat or objc-compat.

Anway...

I probably should close this issue, since I have added a #define isa to objc-compat a few weeks ago. This isn't part of the 0.14 release yet, though.

The 0.15 release will be a fairly big step towards compatibility of MulleFoundation with the Apple Foundation, albeit it's not in a release-worthy state just now unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants