---
title: function()
framework: swift
role: symbol
role_heading: Macro
path: swift/function()
---

# function()

Produces the name of the declaration in which it appears.

## Declaration

```swift
@freestanding(expression) macro function<T>() -> T where T : ExpressibleByStringLiteral
```

## Overview

Overview Inside a function, the value #function produces is the name of that function, inside a method it’s the name of that method, inside a property getter or setter it’s the name of that property, inside special members like init or subscript it’s the name of that keyword, and at the top level of a file it’s the name of the current module. When used as the default value of a function or method parameter, this macro’s value is determined when the default value expression is evaluated at the call site. For example: func logFunctionName(string: String = #function) {     print(string) } func myFunction() {     logFunctionName() // Prints "myFunction()". }

## See Also

### Getting Source Location Information

- [file()](swift/file().md)
- [fileID()](swift/fileid().md)
- [filePath()](swift/filepath().md)
- [line()](swift/line().md)
- [column()](swift/column().md)
