On Wed, Mar 30, 2016 at 10:51 PM, Chris <7hunderstr...@gmail.com> wrote: > 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 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}),
Don't do this, just use a branch. Never construct a type with a type parameter of runtime determined value. The doc should be made very clear to discourage this! > 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.