# Nice way to display functions

**URL:** https://discourse.julialang.org/t/nice-way-to-display-functions/4089
**Category:** General Usage
**Created:** [June 5, 2017, 9:11am UTC](https://discourse.julialang.org/t/nice-way-to-display-functions/4089 "2017-06-05T09:11:06Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)
#### Post date: [June 5, 2017, 2:05pm UTC](https://discourse.julialang.org/t/nice-way-to-display-functions/4089/3 "2017-06-05T14:05:45Z")

</div>

I would use something like:

```julia
immutable ShortFun{T<:Function}
    f::T
    expr
end
# This printing could be made nicer by removing the `begin` that appears. See MacroTools
Base.show(io::IO, sf::ShortFun) = print(io, sf.expr)
# Beware that kwargs will make this slow; remove them if you don't need them
# and performance is a concern
(sf::ShortFun)(args...; kwargs...) = sf.f(args...; kwargs...)
macro shortfun(expr)
    esc(:(ShortFun($expr, $(Expr(:quote, expr)))))
end
f = @shortfun x -> 2+x

```

---

_[View the full topic](https://discourse.julialang.org/t/nice-way-to-display-functions/4089)._
