question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"inline" keyword not accepted next to "fun" keyword

See original GitHub issue

Repost of issue Functions defined as a value can’t be inlined where Don Syme suggested to post it here.

The following two definitions are semantically identical and compiled to exactly the same code:

let add (x : int) (y : int) : int = 
   x + y

let add : int -> int -> int =
    fun x y -> x + y

Yet the inline keyword is not allowed next to fun while it is allowed next to let.

That is:

let inline add (x : int)  (y : int) : int = 
   x + y

compiles, but neither

let add : int -> int -> int =
    inline fun x y -> x + y

nor

let add : int -> int -> int =
    fun inline x y -> x + y

compiles.

I consider this a bug because

let add : int -> int -> int =
    fun x y -> x + y

is valid syntax for defining a function, but making it inline is not supported. It should not make a difference which style I choose. Especially in terms of maintainability - right now - I would have to rewrite the function to add inline which is a considerable and unnecessary inconvenience.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
drvinkcommented, May 23, 2015

Just throwing in my two cents: I’d been meaning to file an issue that you couldn’t do “let inline fn = function | …cases…” for a while, and this issue covers that, so I agree it would be a nice thing to have.

0reactions
dsymecommented, Jul 11, 2016

@amazingant @exercitusvir @21c-HK I’m ok with this this adjustment being made to the language (though I don’t particularly favour its use to write F# code in a non-idiomatic style trying to emulate styles of other languages). So I’ve changed the status of the issue on uservoice to “approved” - though I don’t personally plan to work on the adjustment.

I agree with @brodyberg above that the way to address this is for someone to propose a PR. I suggest starting by finding the place where the current error is raised, e.g. by searching FSComp.txt or other files for the error message text.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inline keyword not recognized in c module compiled inside ...
I am developing an embedded C application in a C90-compliant compiler which, on the other hand, for testing and debugging purposes, is deployed ......
Read more >
Should you use the inline keyword or not? : r/cpp
AFAIU the inline keyword is not a guarantee, it is just a hint that the compiler can consider the function for inlining. The...
Read more >
Inline Functions, C++ FAQ
Therefore the inline keyword should not go within the class's public: (or the protected: or private: ) part, so it needs to go...
Read more >
inline, noinline, crossinline — What do they mean?
Say you have multiple lambdas in your inlined function and you don't want all of them to be inlined, you can mark the...
Read more >
Inline functions in C++. What's the point?
The “inline” keyword allowed the body of a function (method) to be defined in a header file, hence allowing the compiler to make...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found