Heads-up: Change in the string resulting from #function for functions with only unnamed parameters

(Mark Lacey) #1

Just a quick heads up that I have a PR that will land soon that changes the result of #function for functions that only have unnamed parameters. This might matter for you if you're generating log output that includes the string generated by #function since it will result in differences you may not be expecting.

Whereas in the past you would see this result:

func noParams() 
  -> String { return #function } // returns "noParams()"

func unnamedParams(_ i: Int) 
  -> String { return #function } // returns "unnamedParams"

func someNamedParams(_ i: Int, j: Int) 
  -> String { return #function } // returns "someNamedParams(_:j:)"

after my PR lands the result of #function for unnamedParams will change to include the parens and the _: for each parameter:

func unnamedParams(_ i: Int) 
  -> String { return #function } // returns "unnamedParams(_:)"

(Adrian Zubarev) #2

I'm for the consistent behavior. Thanks for letting us know.