Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2594,6 +2594,20 @@ end

Compile the function `f` with arguments `args` and return the compiled function.

## Note

Note that `@compile foo(bar(x))` is equivalent to
```julia
y = bar(x) # first compute the output of `bar(x)`, say `y`
@compile foo(y) # then compile `foo` for `y`
```
That is, like `@jit`, `@compile` only applies to the outermost function call; it does *not* compile the composed function `foo(bar(x))` jointly.
Hence, if you want to compile the composed function `foo(bar(x))` jointly, you need to introduce an intermediate function, i.e.,
```julia
baz(x) = foo(bar(x))
@compile baz(x)
```

## Options

$(SYNC_DOCS)
Expand All @@ -2617,6 +2631,20 @@ end
Run @compile f(args..) then immediately execute it. Most users should use [`@compile`](@ref)
instead to cache the compiled function and execute it later.

## Note

Note that `@jit foo(bar(x))` is equivalent to
```julia
y = bar(x) # first compute the output of `bar(x)`, say `y`
@jit foo(y) # then compile `foo` for `y` and execute it
```
That is, like `@compile`, `@jit` only applies to the outermost function call; it does *not* compile the composed function `foo(bar(x))` jointly.
Hence, if you want to compile the composed function `foo(bar(x))` jointly, you need to introduce an intermediate function, i.e.,
```julia
baz(x) = foo(bar(x))
@jit baz(x)
```

## Options

$(SYNC_DOCS)
Expand Down
Loading