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 J & I used it above, "name" is a field of a 
function object. Thus
f(x)=x^2
sets the name and other fields all at once, so it's never anonymous. In 
particular, it attaches a method for argument type "Any" (since none was 
specified).

Methods are effectively rules for applying the function to tuples of 
argument types.
Methods in turn have "specializations" which seem to be (essentially) the 
compiled code for the specific leaf types of arguments, so
a = f(2.0)
gets Julia to compile a specialization of the (f,Any) method for 
(f,Float64), and save it for later use by stashing it in a subfield of the 
function object.

f(x::Int)=x^2+1
would add another method to the function named "f", just to be used with 
integer arguments.  But
f(x)=x^3
replaces the first method (because it has the same nominal argument type, 
i.e. Any) That is, it replaces it within the object we set up with the 
original definition.
Operations like map, broadcast, and closure construction use and store 
references to parts of the function object (in particular, methods), and 
associate the name "f"
with those references. In Julia v0.5, these references are not updated 
correctly on redefinition. That's what I meant when I said the 
disassociation is incomplete.


On Monday, October 10, 2016 at 3:09:24 PM UTC-4, digxx wrote:
>
> 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 
>> the object named "f". 
>> f(x)=x^2
>>
>
>  so this definition associates the anonymous function with a name (and 
> then it is not anoymous anymore?)
> However how do these method tables look like? In particular the name f is 
> then associated to these methods and for some reason one does not want to 
> be able to change f to refer to different methods?
> How would different mathod attaching look like?
> when I write
>
> f(x)=x^2
> and then
> f(x)=x^3
>
> the old method (is the method here the operation x^2 or x^3?) is still 
> there and x^3 is just attached to it?!?
> is it possible to completely dissociate the old method (in this case as I 
> understand it correctly it is x^2?) with the name f?
>

Reply via email to