This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Objective-C : Do not accept an object as parameter toa method


> >> With this simple patch compiler checks whether (and raise error if
> >> required) an object
> >> is used as parameter to a method or not.  Because it is not a good 
> >> idea
> >> in Objective-C.
> >
> > Errr, whyever not?  It seems like you would *want* that capability.

I was shocked by that sentence too :-) but I think he simply didn't
explain himself properly, the patch seems to do quite another thing.

An object is declared as in (NSObject *) [it's really a pointer to the
actual object] - and unless you do low-level things such as casting it to
a pointer to an appropriate struct etc which you can always do - you must
always pass around pointers/references to objects, rather than the objects
themselves.

His patch looks like preventing something like 'NSObject' to be used as
the type for a method argument ... which would be the hypothetical syntax
to pass the object itself (rather than a pointer to the object) as
argument to a method ... this syntax won't currently work as far as I know
(but the compiler doesn't reject it) - and I agree with Devang it's not a
good idea to make it work :-) it's better to raise an error as that might
catch a common typing mistake (leaving out the '*').

 
> I wonder why we need that?
> Objective-C does not allow statically allocated objects.
> And this is only for class and instance methods. It is not for normal C
> like  functions.

I can see your point in generating an error in this case ... but why the
exception for normal C like functions ?

Shouldn't we generate an error in that case too ?

Can you give me an example of a case in which the syntax for statically
allocated objects is actually used/useful ?  If not, shouldn't we disable
it everywhere, not only for ObjC methods ?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]