Skip to content

Annotate @doc metadata when a function is inlined #7905

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

Closed
wants to merge 1 commit into from
Closed

Annotate @doc metadata when a function is inlined #7905

wants to merge 1 commit into from

Conversation

fertapric
Copy link
Member

@fertapric fertapric commented Jul 15, 2018

I've seen the documentation of some functions contains "Inlined by the compiler" and I thought it would be a nice addition to include that information in the @doc metadata.

I was going to ask first in the mailing list, but the changes were quite straightforward and I decided to give it a go :)

@josevalim
Copy link
Member

josevalim commented Jul 15, 2018 via email

@fertapric
Copy link
Member Author

Right. I did not think about other languages running on the Erlang VM.

@whatyouhide
Copy link
Member

@fertapric it's not just about other languages, I would say it's mostly about the fact that we only inline in Elixir code, so code written in Elixir and using ExDoc would not be able to use :inline.

Personally, I don't think we gain a lot by having this in ExDoc as it feels we're basically moving the line that says "Inlined by the compiler" from the docs to a doc attribute without making use of the doc attribute in any meaningful way (other than displaying it on ExDoc, which is already achieved by putting it in the docs though). So for me it's 👎 as well.

@fertapric
Copy link
Member Author

@fertapric it's not just about other languages, I would say it's mostly about the fact that we only inline in Elixir code, so code written in Elixir and using ExDoc would not be able to use :inline.

I was thinking in letting developers use @doc inline: true when they use @compile {:inline, some_fun: 2, other_fun: 3}. Here is an example outside the Elixir codebase.

The main goal of this flag would be to standardize how Elixir functions are marked when they are inlined. Right now, if developers want to express that, they need to follow the convention established in this sentence of the Kernel docs:

Those functions will be explicitly marked in their docs as "inlined by the compiler".

But I don't have a strong opinion on this. So, if you are not 100% sure about this PR, I think it's better to close it. It's always easier to add than to remove :)

@fertapric fertapric closed this Jul 15, 2018
@fertapric fertapric deleted the fertapric-annotate-doc-metadata-when-inlined branch July 15, 2018 13:45
@josevalim
Copy link
Member

josevalim commented Jul 15, 2018 via email

@fertapric
Copy link
Member Author

In particular, the flag has no behavior for callers outside of the module.

I did not know that 😅

The @compile :inline flag is very different from the inlines behavior we are describing here

I guess the list of "Inlined by the compiler" functions is this one.

One question: the functions of the Map module that appear on the list of functions "Inlined by the compiler" are Map.keys/1, Map.merge/2, Map.size/1, Map.to_list/1, and Map.values/1, but the functions Map.has_key?/2, Map.fetch/2, Map.fetch!/2, Map.replace!/3, Map.put/3, and Map.delete/2 state in their documentation that they are "Inlined by the compiler", is that correct?

@fertapric
Copy link
Member Author

Nevermind. I see they are rewritten here.

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

Successfully merging this pull request may close these issues.

3 participants