That regex is a bit literal, and I should have been clearer, semantic not exact syntax, i.e.: x = expr ; x x = expr ; return x x = expr x x = expr return x
For example, things like this, in symmetric.jl: retmat = (F.vectors * Diagonal(($func)(complex(F.values)))) * F.vectors' return retmat On Thursday, September 17, 2015 at 11:10:45 AM UTC-4, Stefan Karpinski wrote: > > Do you really? I just ran this regex r"^\s*(\w+)\s*=.*;\s*\1\s*$" on > Julia's code base and all .jl files in all the packages I have installed > for both 0.3 and 0.4 and there are zero matches. > > On Wed, Sep 16, 2015 at 5:52 PM, Scott Jones <[email protected] > <javascript:>> wrote: > >> This is why you see frequently in Julia functions: >> x = expr ; x >> >> >> >> On Wednesday, September 16, 2015 at 5:25:15 PM UTC-4, ggggg wrote: >>> >>> That makes a lot of sense, thanks. >>> >>> On Wednesday, September 16, 2015 at 2:22:54 PM UTC-6, Spencer Russell >>> wrote: >>>> >>>> There’s an issue where Jeff describes the reasoning here: >>>> https://github.com/JuliaLang/julia/issues/5532 >>>> >>>> On Sep 16, 2015, at 3:57 PM, j verzani <[email protected]> wrote: >>>> >>>> The return value of the function is value of the last expression >>>> evaluated. For assignment, the right-hand side is always returned. So in >>>> `f` you get the value x*2.0 returned which is 2.0. >>>> >>>> On Wednesday, September 16, 2015 at 3:41:22 PM UTC-4, ggggg wrote: >>>>> >>>>> I was playing around with type declarations and came across an >>>>> counterintuitive result. I'm not sure if this is the intended behavior or >>>>> not, but it certainly surprised me. >>>>> >>>>> Consider the functions >>>>> >>>>> *function f(x)* >>>>> >>>>> *y::Int* >>>>> >>>>> *y=x*2.0* >>>>> >>>>> *end* >>>>> >>>>> *function g(x)* >>>>> >>>>> *y::Int* >>>>> >>>>> *y=x*2.0* >>>>> >>>>> *y* >>>>> >>>>> *end* >>>>> >>>>> *julia> **f(1),g(1)* >>>>> >>>>> *(2.0,2)* >>>>> >>>>> I expected them to behave identically, always returning an Int. But >>>>> clearly f returns a Float64. >>>>> >>>>> >>>>> It seems like in the presence of the type delaration y=x*2.0 is >>>>> interpreted as >>>>> >>>>> temp=x*2.0 >>>>> >>>>> y=Int(temp) >>>>> >>>>> temp >>>>> >>>>> is that right? >>>>> >>>> >>>> >
