On Mon, May 30, 2016 at 2:09 PM, Ford Ox <
ford...@gmail.com> 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