On Mon, May 30, 2016 at 2:09 PM, Ford Ox <[email protected]> wrote:
> Yeah I have read it. Multiple times, since I forget things and I still don't
> remember all the things.
>
> So basically the difference is that bitwise operators are functions. That
> means its arguments get evaluated before they are passed in. That also
> means, that if that function would be inlined, && would be same as &
> because:

No. function inlining is a pure optimization that doesn't affect the
schematics of the program at all.

>
> &(x::Bool, y::Bool) = box(Bool,and_int(unbox(Bool,x),unbox(Bool,y)))
> I dont really understand that function, since I dont know what box, unbox
> is, but I guess it is something like
> &(x::Bool, y::Bool) = x && y

They do have similar effect.

> so if & would be inlined before x, y are evaluated, than && and & would have
> identical meaning ( for booleans ), right?

No. inlining is irrelevant.

>
> I was trying to achieve that with @generated, but it didn't work.
> function x()
>     println("x")
>     true
> end
> function y()
>     println("y")
>     false
> end
> @generated and_gen(x::Bool, y::Bool)
>     return :(x && y)
> end
>
> and_gen(y(), x())
>
>> y
>>
>> x
>>
>> false
>
>
> Which is kinda weird, since x and y always returns Bool, so @generated
> should know types of x() and y() before their evaluation.
> and_gen(y()::Bool, x()::Bool) # also doesn't work
>
>
>
>
> On Monday, May 30, 2016 at 1:19:05 PM UTC+2, Tamas Papp wrote:
>>
>> See
>>
>>
>> http://docs.julialang.org/en/release-0.4/manual/control-flow/#man-short-circuit-evaluation
>>
>> A lot of effort went into writing and improving the language manual, so
>> that you can find very detailed answers to questions like this one. It
>> is fine to ask on the list if you can't find it, but giving the whole
>> manual a read is very useful for new users of Julia.
>>
>> On Mon, May 30 2016, Ford Ox wrote:
>>
>> > Ye I know what bitwise operator does.
>> > I will ask in different way, maybe it will be clearer to you.
>> >
>> > Why people use logical operators ( f.e. in conditions ) instead of
>> > bitwise
>> > operators? Is && <: & ?
>> >
>> >
>> > On Monday, May 30, 2016 at 9:58:02 AM UTC+2, Kaj Wiik wrote:
>> >>
>> >>
>> >> Here's a clue:
>> >>
>> >>
>> >> julia> 0b10010011 & 0b10010011
>> >> 0x93
>> >>
>> >> julia> 0b10010011 && 0b10010011
>> >> ERROR: TypeError: non-boolean (UInt8) used in boolean context
>> >>
>> >>
>> >> Kaj
>> >>
>> >>
>> >> On Monday, May 30, 2016 at 9:30:22 AM UTC+3, Ford Ox wrote:
>> >>>
>> >>> For example
>> >>> true & false == true && false
>> >>>
>> >>> Is it just artifact from c where bool types don't exist?
>> >>>
>> >>

Reply via email to