i don't know of a good way to do this.

really, parameterised modules would be great.

the simplest thing i can think of is if modules are first class and using 
etal can take an expression, but the following doesn't run:

module A
foo() = println("a")
end

module B
foo() = println("b")
end

module AB
m(x) = x ? A : B
end

using AB
using m(true)
foo()  # wouldn't it be nice if this printed "a"?

andrew


On Sunday, 13 September 2015 19:33:16 UTC-3, Seth wrote:
>
> Hi all,
>
> I'd like to track a setting throughout my module (that will cause the 
> [transparent] dispatch of either single-threaded or parallel versions of 
> many different functions). Is there a more Julian way of doing the 
> following? This seems inelegant:
>
> _parallel = false    # start off without parallelism - user calls 
> parallelize() to set/unset.
>
> function parallelize(p::Bool=true)
>     global _parallel = p
> end
>
>
> function foo(a::Int) # there will be many functions like this
>   if _parallel
>      _foo_parallel(a)
>   else
>     _foo_singlethread(a)
>   end
> end
>
>

Reply via email to