Re: [julia-users] const functions

2016-04-12 Thread Yichao Yu
On Tue, Apr 12, 2016 at 7:56 AM, Mauro wrote: > On Tue, 2016-04-12 at 13:47, Didier Verna wrote: >> Mauro wrote: >> >>> yes, this just binds a function to a variable. This also works: >>> >>> julia> foo() = 1 >>> foo (generic function with 1 method) >>> >>> julia> bar = foo >>> foo (generic fun

Re: [julia-users] const functions

2016-04-12 Thread Mauro
On Tue, 2016-04-12 at 13:47, Didier Verna wrote: > Mauro wrote: > >> yes, this just binds a function to a variable. This also works: >> >> julia> foo() = 1 >> foo (generic function with 1 method) >> >> julia> bar = foo >> foo (generic function with 1 method) >> >> julia> bar = 2 >> 2 > > OK, s

Re: [julia-users] const functions

2016-04-12 Thread Didier Verna
Mauro wrote: > yes, this just binds a function to a variable. This also works: > > julia> foo() = 1 > foo (generic function with 1 method) > > julia> bar = foo > foo (generic function with 1 method) > > julia> bar = 2 > 2 OK, so IIUC, defining a toplevel function is not strictly equivalent

Re: [julia-users] const functions

2016-04-12 Thread Mauro
On Tue, 2016-04-12 at 11:40, Didier Verna wrote: > What's the rationale behind making "function" const? Is there a > performance reason? Yes, globals need to be const to be fast. > you can't do > > function foo() 0 end > foo = 10 > > but you can still change the function's definition (so it

[julia-users] const functions

2016-04-12 Thread Didier Verna
What's the rationale behind making "function" const? Is there a performance reason? you can't do function foo() 0 end foo = 10 but you can still change the function's definition (so it's methods; even if the generic remains the same object I guess), and besides, you can however do this: ba