@@ -307,7 +307,7 @@ generated thunks.
307
307
macro par (exs... )
308
308
opts = exs[1 : end - 1 ]
309
309
ex = exs[end ]
310
- return esc (_par (ex; lazy= true , opts= opts))
310
+ return esc (_par (__module__, ex; lazy= true , opts= opts))
311
311
end
312
312
313
313
"""
@@ -349,7 +349,7 @@ also passes along any options in an `Options` struct. For example,
349
349
macro spawn (exs... )
350
350
opts = exs[1 : end - 1 ]
351
351
ex = exs[end ]
352
- return esc (_par (ex; lazy= false , opts= opts))
352
+ return esc (_par (__module__, ex; lazy= false , opts= opts))
353
353
end
354
354
355
355
struct ExpandedBroadcast{F} end
365
365
366
366
to_namedtuple (;kwargs... ) = (;kwargs... )
367
367
368
- function _par (ex:: Expr ; lazy= true , recur= true , opts= ())
368
+ function _par (mod, ex:: Expr ; lazy= true , recur= true , opts= ())
369
369
f = nothing
370
+ bf = nothing
370
371
body = nothing
371
372
arg1 = nothing
372
373
arg2 = nothing
@@ -375,7 +376,11 @@ function _par(ex::Expr; lazy=true, recur=true, opts=())
375
376
@capture (ex, allargs__-> body_) ||
376
377
@capture (ex, arg1_[allargs__]) ||
377
378
@capture (ex, arg1_. arg2_) ||
378
- @capture (ex, (;allargs__))
379
+ @capture (ex, (;allargs__)) ||
380
+ @capture (ex, bf_ .(allargs__))
381
+ if bf != = nothing
382
+ f = ExpandedBroadcast {mod.eval(bf)} ()
383
+ end
379
384
f = replace_broadcast (f)
380
385
if arg1 != = nothing
381
386
if arg2 != = nothing
@@ -429,15 +434,15 @@ function _par(ex::Expr; lazy=true, recur=true, opts=())
429
434
end
430
435
elseif lazy
431
436
# Recurse into the expression
432
- return Expr (ex. head, _par_inner .(ex. args, lazy= lazy, recur= recur, opts= opts)... )
437
+ return Expr (ex. head, _par_inner .(Ref (mod), ex. args, lazy= lazy, recur= recur, opts= opts)... )
433
438
else
434
439
throw (ArgumentError (" Invalid Dagger task expression: $ex " ))
435
440
end
436
441
end
437
- _par (ex; kwargs... ) = throw (ArgumentError (" Invalid Dagger task expression: $ex " ))
442
+ _par (mod, ex; kwargs... ) = throw (ArgumentError (" Invalid Dagger task expression: $ex " ))
438
443
439
- _par_inner (ex; kwargs... ) = ex
440
- _par_inner (ex:: Expr ; kwargs... ) = _par (ex; kwargs... )
444
+ _par_inner (mod, ex; kwargs... ) = ex
445
+ _par_inner (mod, ex:: Expr ; kwargs... ) = _par (mod, ex; kwargs... )
441
446
442
447
"""
443
448
Dagger.spawn(f, args...; kwargs...) -> DTask
0 commit comments