Skip to content

Commit 4d6eee0

Browse files
committed
Expand @static docstring
1 parent 4a4d850 commit 4d6eee0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

base/osutils.jl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
66
Partially evaluate an expression at parse time.
77
8-
For example, `@static Sys.iswindows() ? foo : bar` will evaluate `Sys.iswindows()` and insert
9-
either `foo` or `bar` into the expression.
10-
This is useful in cases where a construct would be invalid on other platforms,
11-
such as a `ccall` to a non-existent function.
12-
`@static if Sys.isapple() foo end` and `@static foo <&&,||> bar` are also valid syntax.
8+
This is useful in cases where a construct would be invalid in some cases, such as a `ccall`
9+
to a os-dependent function, or macros defined in packages that are not imported.
10+
11+
`@static` requires a conditional. The conditional can be in an `if` statement, a ternary
12+
operator, or `&&`\`||`.
13+
14+
# Example
15+
16+
Suppose we want to parse an expression `expr` that is valid only on MacOS. We could solve
17+
this problem using `@static` with `@static if Sys.isapple() expr end`. In case we had
18+
`expr_apple` for MacOS and `expr_others` for the other operating systems, the solution with
19+
`@static` would be `@static Sys.isapple() ? expr_apple : expr_others`.
1320
"""
1421
macro static(ex)
1522
if isa(ex, Expr)

0 commit comments

Comments
 (0)