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

x/mobile/bind: lowercase function names for objC #12889

Closed
scisci opened this issue Oct 9, 2015 · 7 comments
Closed

x/mobile/bind: lowercase function names for objC #12889

scisci opened this issue Oct 9, 2015 · 7 comments

Comments

@scisci
Copy link

scisci commented Oct 9, 2015

This is definitely just a nice-to-have!

In order to comply with style guidelines for objective c and swift, it would be nice if the gomobile bind command had an option to lowercase the first character of exported function names.

@hyangah
Copy link
Contributor

hyangah commented Oct 9, 2015

yes, I am thinking about converting all method names to start with lowercase. Any objection?

@crawshaw
Copy link
Member

crawshaw commented Oct 9, 2015

SGTM (Doing it automatically that is. I'd like to minimize the number of options.)

@rakyll rakyll added this to the Unreleased milestone Oct 9, 2015
@rakyll
Copy link
Contributor

rakyll commented Oct 9, 2015

SGTM, method names must start with lowercase in both languages.

@gopherbot
Copy link

CL https://golang.org/cl/15780 mentions this issue.

@hyangah
Copy link
Contributor

hyangah commented Oct 12, 2015

I have a draft cl l for objective-c (cl/15780). Avoiding name conflicts seems tricky.

  1. what if the lower-case'd method names override NSObject's method names (ex. Init)
  2. what if the struct has an exported field Foo, and has a method SetFoo?
  3. what if the lower-case'd method names turn out to be objective-c or swift keywords that cannot be used as identifiers (ex. Do)

Similar exceptions will occur for Java too.

@crawshaw
Copy link
Member

I think it's worth attempting to do this anyway, because the visible effect on the code is to make it look far more like Obj-C.

For conflicts, a carefully placed suffix calculated recursively (_1, _2, etc) can work. Both your points 1 and 3 can be covered by a static list of identifiers, for 2 it is a per-object list of identifiers.

gopherbot pushed a commit to golang/mobile that referenced this issue Sep 7, 2016
There was a discussion a year ago about making methods and types
lowercase in ObjC (golang/go#12889),
which was done (https://go-review.googlesource.com/#/c/15780/),
alas the suggested Java lower casing was never addressed.

This CL converts all generated Java methods to lower case.

Change-Id: Ia2f28519bc59362877881636109ddfc651b24960
Reviewed-on: https://go-review.googlesource.com/28494
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
@hyangah
Copy link
Contributor

hyangah commented Sep 8, 2016

need to update documentation https://godoc.org/golang.org/x/mobile/cmd/gobind

It seems that some of name conversions (due to conflicts with reserved keywords) are not intuitive.

@golang golang locked and limited conversation to collaborators Sep 8, 2017
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Fixes golang/go#12889.

Change-Id: I4b8f5e4b2c4fe53146fc351889664cbeb5a1860b
Reviewed-on: https://go-review.googlesource.com/15780
Reviewed-by: David Crawshaw <crawshaw@golang.org>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Fixes golang/go#12889.

Change-Id: I4b8f5e4b2c4fe53146fc351889664cbeb5a1860b
Reviewed-on: https://go-review.googlesource.com/15780
Reviewed-by: David Crawshaw <crawshaw@golang.org>
@rsc rsc unassigned hyangah Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants