[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cc-mode Objective C method names

From: Alan Third
Subject: Re: cc-mode Objective C method names
Date: Thu, 2 Jan 2020 11:02:30 +0000

On Wed, Jan 01, 2020 at 10:29:42AM -0500, Stefan Monnier wrote:
> > And I think the methods’ names should be written something like:
> >
> > -[ClassName doSomething]
> > -[ClassName doSomethingTo:with:]
> These names look very odd to me (as a non-ObjC coder, I find the
> brackets rather ugly and useless for example), but if they're the
> "normal" way to refer to them, then I guess it's fine.

I think it’s the normal way, I’m not very clear as there are very few
examples of people referring to methods without the class being
already known.

For example Apple’s documentation only ever refers to methods like this:

- initWithFrame:

or like this:

- (instancetype)initWithFrame:(NSRect)frameRect;

but in neither case does it tell you which class it’s from, you have
to pick it up from other clues on the page.

> > The ‘-’ means it’s an instance method and a ‘+’ would mean it was a
> > class method.
> Might be best not to include it: how often do you have both a class
> method and an instance method with the same name?
> [ E.g. in Elisp we use the function names and variable names as is,
>   without clarifying if it's a function name or a variable name.  ]

It happens quite often, but not in the Emacs code base, which is
presumably the only place this is of use. So I’ll get rid of that.

> > It appears to work for me, but I’m not great at Emacs lisp so I
> > thought it best to run this by the mailing list in case I’ve made any
> > boneheaded errors.
> This is the code of the other Alan and I'm not very familiar with this
> part of CC-mode, so don't take my opinion too seriously, but it looks
> acceptable to me.

I’ll wait a while and see if he has any comments.

> > +                      (if (looking-at "(")
> > +                          (c-forward-token-2 2 t)
> > +                        (c-forward-token-2 1 t))
>                          (c-forward-token-2 (if (looking-at "(") 2 1) t)

Alan Third

reply via email to

[Prev in Thread] Current Thread [Next in Thread]