See #18367 <https://github.com/JuliaLang/julia/issues/18367> and #19168
<https://github.com/JuliaLang/julia/issues/19168>.

On Mon, Oct 31, 2016 at 3:06 PM, Stefan Karpinski <ste...@karpinski.org>
wrote:

> At the moment no, although there's been discussion of making Bool not a
> subtype of Number.
>
> On Mon, Oct 31, 2016 at 2:29 PM, Penn Taylor <rpe...@gmail.com> wrote:
>
>> Is there a way to prevent automatic conversion/promotion between Bool and
>> Number types?
>>
>> Motivating examples:
>>
>> type Bools
>>   a::Bool
>>   b::Bool
>> end
>>
>> Bools(1, 0) #=> Bools(true,false)
>>
>> type Ints
>>   a::Int64
>>   b::Int64
>> end
>>
>> Ints(true, false) #=> Ints(1,0)
>>
>> In both of the above cases, I want the construction to fail.
>>
>> I'm aware that I could write constructors for these types to explicitly
>> reject Bool<->Number mismatch, but that gets tedious when there are more
>> than a few Number or Bool fields in a type. Wondering if there's an easier
>> way.
>>
>
>

Reply via email to