Yes. But we are talking about our observations, not about language design or intentions. (And we also observe:typeof(foo)===typeof(wtf)
)
wtf2() = show("new function") # this create function object too. and binding it to wtf2 name
wtf2(x) = 7 # this add new method
# IMHO from language design POV this is doable too:
_wtf2 = () -> show("new function")
addmethod!(_wtf, (x) -> 7) # why not expose full potential of function object?
So now it seems that we have two possibilities:
wtf() = 7
which is crippling possibility to “decorate”/“copy” code
_wtf = () ->7
which is crippling possibility to add methods.
edit:
3. foo() = 7; __wtf = foo
where foo could help to add methods but pollute namespace and worsening readability
Btw:
julia> function a1() foo() end;
julia> @code_llvm a1()
; Function a1
; Location: REPL[33]:1
define i64 @julia_a1_57933() {
top:
ret i64 7
}
julia> function a2() __wtf() end;
julia> @code_llvm a2()
; Function a2
; Location: REPL[35]:1
define nonnull %jl_value_t addrspace(10)* @japi1_a2_57940(%jl_value_t addrspace(10)*, %jl_value_t addrspace(10)**, i32) #0 {
top:
%3 = alloca %jl_value_t addrspace(10)*, align 8
%gcframe1 = alloca [3 x %jl_value_t addrspace(10)*], align 8
%gcframe1.sub = getelementptr inbounds [3 x %jl_value_t addrspace(10)*], [3 x %jl_value_t addrspace(10)*]* %gcframe1, i64 0, i64 0
%4 = getelementptr inbounds [3 x %jl_value_t addrspace(10)*], [3 x %jl_value_t addrspace(10)*]* %gcframe1, i64 0, i64 1
%5 = bitcast %jl_value_t addrspace(10)** %4 to i8*
call void @llvm.memset.p0i8.i32(i8* %5, i8 0, i32 16, i32 8, i1 false)
%6 = alloca %jl_value_t addrspace(10)**, align 8
store volatile %jl_value_t addrspace(10)** %1, %jl_value_t addrspace(10)*** %6, align 8
%thread_ptr = call i8* asm "movq %fs:0, $0", "=r"() #2
%ptls_i8 = getelementptr i8, i8* %thread_ptr, i64 -10920
%7 = bitcast [3 x %jl_value_t addrspace(10)*]* %gcframe1 to i64*
store i64 2, i64* %7, align 8
%8 = getelementptr [3 x %jl_value_t addrspace(10)*], [3 x %jl_value_t addrspace(10)*]* %gcframe1, i64 0, i64 1
%9 = bitcast i8* %ptls_i8 to i64*
%10 = load i64, i64* %9, align 8
%11 = bitcast %jl_value_t addrspace(10)** %8 to i64*
store i64 %10, i64* %11, align 8
%12 = bitcast i8* %ptls_i8 to %jl_value_t addrspace(10)***
store %jl_value_t addrspace(10)** %gcframe1.sub, %jl_value_t addrspace(10)*** %12, align 8
%13 = load i64, i64* inttoptr (i64 140211137321128 to i64*), align 8
%14 = getelementptr [3 x %jl_value_t addrspace(10)*], [3 x %jl_value_t addrspace(10)*]* %gcframe1, i64 0, i64 2
%15 = bitcast %jl_value_t addrspace(10)** %14 to i64*
store i64 %13, i64* %15, align 8
%16 = bitcast %jl_value_t addrspace(10)** %3 to i64*
store i64 %13, i64* %16, align 8
%17 = call nonnull %jl_value_t addrspace(10)* @jl_apply_generic(%jl_value_t addrspace(10)** nonnull %3, i32 1)
%18 = load i64, i64* %11, align 8
store i64 %18, i64* %9, align 8
ret %jl_value_t addrspace(10)* %17
}