You are pointing out differences in the parsed AST. As Jameson said the two forms are equivent and will get lowered by the compiler to the same code. I suggest browsing though Julia's type inference / compiler code to get a better overview of how things work under the hood.
Best, Jake On Sunday, February 16, 2014 10:16:28 PM UTC-5, Fil Mackay wrote: > > On Mon, Feb 17, 2014 at 1:02 PM, Jameson Nash <[email protected]<javascript:> > > wrote: > >> Fil, your second form of writing the function is functionally >> identical to the first -- it is only a difference in syntax and makes >> absolutely no difference to the compiler. > > > There are differences to the compiler: > > julia> dump(:(x->x)) > Expr > head: Symbol -> > args: Array(Any,(2,)) > 1: Symbol x > 2: Expr > head: Symbol block > args: Array(Any,(2,)) > 1: Expr > head: Symbol line > args: Array(Any,(2,)) > typ: Any > 2: Symbol x > typ: Any > typ: Any > > julia> dump(:(function (x); x; end)) > Expr > head: Symbol function > args: Array(Any,(2,)) > 1: Expr > head: Symbol tuple > args: Array(Any,(1,)) > 1: Symbol x > typ: Any > 2: Expr > head: Symbol block > args: Array(Any,(2,)) > 1: Expr > head: Symbol line > args: Array(Any,(2,)) > typ: Any > 2: Symbol x > typ: Any > typ: Any > > These differences (-> / function) could make a real difference to type > inference, and seem to from the local/const examples. >
