Here's my current dilemma, (hopefully) explained by this simple example:

I have a composite type that has a bool field:

type A
  x::Float64
  b::Bool
end

I have a function with different behavior based on the value of A.b. The 
manual <http://docs.julialang.org/en/release-0.4/manual/types/#value-types> 
suggests 
the following solution:

function dothing(a::A, ::Type{Val{false}})
   ...
end

function dothing(a::A, ::Type{Val{true}})
  ...
end

That's fine, but now I have to call the function as dothing(a, Val{a.b}), 
which just strikes me as slightly redundant/verbose. Is there some way to 
make this more compact, i.e. just dothing(a), while still avoiding the 
check of a.b inside the function? Perhaps parameterizing the type A itself?

Hopefully I made myself relatively clear. Thanks in advance.

Reply via email to