-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[Blocking] Function keyword: fn
or func
?
#463
Comments
fn
or func
?fn
or func
?
One set of concerns with On that note, I want to surface one remaining concern that I have with First, why does this keyword matter that much? I want us to consider this choice quite carefully because function declarations are a primary component of API descriptions and so extremely frequently read and scanned by humans. Readability, scanning, skimming, and such concerns are very large for this specific keyword. However, a large fraction (likely a majority?) of functions that are read so often will in fact be methods. While the original placeholder overview suggested syntax like
Here, the introducer would be
I'm not thrilled with the use of So I think we either need to the same introducer ( Thoughts? @carbon-language/carbon-leads @josh11b specifically as I know he's thought a lot about the method syntax. |
I really appreciate the brevity of given how common we expect methods to be, even |
FWIW, I'm also very tempted by the brevity of |
I would turn the question around: is there any well known language that has both functions and methods, and that has introducers for function definitions, and that uses a different introducer for methods than for functions? I'm not aware of any. What we're thinking of for Carbon method definitions (both in structs and in interfaces) looks an awful lot like Go and Rust. Go uses Whatever introducer we choose, I really want to have just one of them instead of two. |
Objective-C uses
I think I agree. I don't immediately see an issue with replacing
... though I think this is still more verbose than I'd prefer. At the risk of heading off-topic, I also wonder if a declaration syntax mirroring the use syntax would be better here:
|
I considered the
it should actually be an arrow, since the
Terrible idea:
|
I'd really like to focus this thread on just the introoducer keyword please. =D I can see this starting to drift and I'd like too pull it back. |
I think based on the "thumbs up" above and posts that we have consensus here to use Would like confirmation from @zygoloid and @KateGregory and I think we can resolve this. |
Have confirmation from @KateGregory and already had a private discussion with @zygoloid, so I think I'm being too conservative here. =D I think all of the leads are clearly aligned around the answer here:
|
#438 proposes a syntax for functions. Although
fn
has been used as a placeholder, the proposal is intended to formalize the format.The "Function keyword" alternative goes over options in more depth. The
fn
orfunc
conclusion is based on discussion on Discord.I've asked Chandler for his leaning on this, he's following up with research and for a leads decision. This issue is tracking that discussion. :)
The text was updated successfully, but these errors were encountered: