Skip to content

Commit

Permalink
underscore macro
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeInnes committed Nov 22, 2014
1 parent b1dc593 commit e4fedfc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/macros.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Threading macros

export @>, @>>, @as, @switch, @or, @dotimes, @once_then, @defonce, isexpr, namify
export @>, @>>, @as, @_, @switch, @or, @dotimes, @once_then, @defonce, isexpr, namify

isexpr(x::Expr, ts...) = x.head in ts
isexpr(x, ts...) = any(T->isa(T, Type) && isa(x, T), ts)
Expand Down Expand Up @@ -71,6 +71,10 @@ macro as (as, exs...)
esc(thread(exs...))
end

macro _ (args...)
:(@as $(esc(:_)) $(map(esc, args)...))
end

macro or (exs...)
thread(x) = isexpr(x, :block) ? thread(subexprs(x)...) : x

Expand Down

0 comments on commit e4fedfc

Please sign in to comment.