This is indeed fairly confusing, partly because the terminological
conventions of functional programming are somewhat arbitrary. Some of my
discussion upthread
uses these conventions, but some (e.g. my use of "attach" and
"associate/dissociate") may not be conventional.
In Julia, and as Steven
>
> The function object then points into
> method tables. You can't assign the name "f" to a different function
> object, just attach different methods to it. The troubles seem to arise
> from cached references to
> orphaned method table entries, which are not completely dissociated from
>
>
> No, it has a name "f". An anonymous function is an expression like "x ->
> x^2" that creates a function object without binding it to a constant name.
>
Ok, but from my feeling also
f=x->x^2
binds this function object to the name f since thats how it is called?
Right?
On Saturday, October 8, 2016 at 5:09:19 PM UTC-4, digxx wrote:
>
> is f(x)=x^2 not an anonymous function?!?!
>
No, it has a name "f". An anonymous function is an expression like "x ->
x^2" that creates a function object without binding it to a constant name.
By "module file" I just meant a source code file where all definitions are
enclosed in modules, so if you "include" it, it replaces the whole module.
Thus
module M
function f(x)
x^2
end
end
then references to M.f are more likely to be consistent than a bare
function f defined at the top
is f(x)=x^2 not an anonymous function?!?!
Maybe one sidenote:
So what is the difference between
f(x)=x^2
and
f=x->x^2
since the last one does not return that warning?
Thanks for ur example
I'm not that familiar with it but what do u mean by "module files"?
Do you have an example and why are they less dangerous?
The problem is that some Julia processing stores references to definitions
in hidden locations which are not updated consistently, so you get
inconsistency like this:
julia> f(x)=x^2
f (generic function with 1 method)
julia> map(f,[1,2,3])
3-element Array{Int64,1}:
1
4
9
julia>
Hey,
Thx for ur answer. So The first time I call my program which includes a
file with function definitions there is no problem. I do this because with
0.4 parallel loops didnt work with functions which are defined in the same
file even though an @everywhere is prefixed.
I still dont understand
TL;DR: put everything in modules.
"WARNING: Method definition ... overwritten..."
This warning was extended to more cases in v0.5. It has caused some
confusion, and some available explanations are themselves confusing. Here
is another try.
Overwriting a method (or type) has always been a
11 matches
Mail list logo