!WTvnrBXAWIqKuxyqrR:matrix.org

Julia (lang)

314 Members
General help and discussion about the Julia language36 Servers

Load older messages


SenderMessageTime
8 Dec 2023
@csantosb:matrix.orgcsantosb joined the room.21:58:16
10 Dec 2023
@malte:maltee.de@malte:maltee.de is there an easy way to use use a negative sign in connections of the connect function of RobustAndOptimalControl? 19:29:37
14 Dec 2023
@benjamin:matrix.benjamin-knopp.debenjamin changed their profile picture.13:36:58
26 Dec 2023
@malte:maltee.de@malte:maltee.deIs this room still alive or is this the widow of a libera.chat bridged room with all the action happening on the IRC side?08:52:15
@rollskatflat:matrix.orgrollskatflatPeople still use IRC a lot?09:51:26
@malte:maltee.de@malte:maltee.de¯\_(ツ)_/¯09:52:46
@malte:maltee.de@malte:maltee.deI noticed julialang.org mentions zulip, slack and discord, so this room is unofficial?09:53:22
27 Dec 2023
@vchuravy:matrix.orgvchuravy it's not yet active enough to be official  14:22:32
@malte:maltee.de@malte:maltee.deHas anyone ever suggested to bridge the different channels? I know slack and discord can be bridged to matrix. Having multiple channels on multiple platforms seems quite inefficient.14:55:05
28 Dec 2023
@hasnep:matrix.orgHannesI know the Julia Slack can be strict about not archiving the messages on there in any way because they like the ephemeral disappearing messages, so they'd probably be against a bridge01:46:30
@dionisos:matrix.orgdionisos

Hi, I am trying to pass a type as an argument of a function, which create other function, using this type (to avoid type instability). But I get this error:

ERROR: LoadError: syntax: local variable NodeType cannot be used in closure declaration

17:29:43
@dionisos:matrix.orgdionisos *

Hi, I am trying to pass a type as an argument of a function, which create other functions, using this type (to avoid type instability). But I get this error:

ERROR: LoadError: syntax: local variable NodeType cannot be used in closure declaration

18:02:19
@dionisos:matrix.orgdionisos
function create_function(Type)
	function test(a::Type, b::Type)
		return a+b
	end
	return test
end

test = create_function(Int)
18:03:41
@dionisos:matrix.orgdionisos

ERROR: LoadError: syntax: local variable Type cannot be used in closure declaration

18:04:07
@dionisos:matrix.orgdionisos *
function create_function(MyType)
	function test(a::MyType, b::MyType)
		return a+b
	end
	return test
end

test = create_function(Int)
18:04:33
@dionisos:matrix.orgdionisos *

ERROR: LoadError: syntax: local variable MyType cannot be used in closure declaration

18:04:38
@dionisos:matrix.orgdionisosIn fact it is obvious it doesn’t work, given that MyType is given at runtime. But I suppose there is some other ways to avoid type instability in these kinds of cases.18:07:23
@dionisos:matrix.orgdionisos *

Hi, I am trying to pass a type as an argument to a function, which create other functions, using this type (to avoid type instability). But I get this error:

ERROR: LoadError: syntax: local variable NodeType cannot be used in closure declaration

18:39:38
@qwjyh:matrix.orgqwjyh

If the type need only one function, then you can use

function (v::MyType)(a::MyType, b::MyType)
    ...
end

https://github.com/FluxML/Flux.jl/blob/df468ba0a10d86b660eebed98d1b484cbce113a7/src/layers/basic.jl#L170

If the type need two or more functions, define a new method with the type on the first argument. e.g. https://github.com/JuliaStats/Distributions.jl/blob/b2d765246e0f35473fe354dc578a3f7edf11958d/src/univariate/continuous/uniform.jl#L74

19:43:03
@qwjyh:matrix.orgqwjyh *

If the type need only one function, then you can use

function (v::MyType)(a::MyType, b::MyType)
    ...
end

https://github.com/FluxML/Flux.jl/blob/df468ba0a10d86b660eebed98d1b484cbce113a7/src/layers/basic.jl#L170

If the type need two or more functions, define a new method with the type on the first argument like Base.parse.

19:51:01
@qwjyh:matrix.orgqwjyh* If the type need only one function, then you can use function (v::MyType)(a::MyType, b::MyType) ... end https://github.com/FluxML/Flux.jl/blob/df468ba0a10d86b660eebed98d1b484cbce113a7/src/layers/basic.jl#L170 If the type need two or more functions, it is common to define a new method with the type on the first argument like Base.parse. 22:55:07
@dionisos:matrix.orgdionisos
In reply to @qwjyh:matrix.org
If the type need only one function, then you can use
function (v::MyType)(a::MyType, b::MyType)
...
end
https://github.com/FluxML/Flux.jl/blob/df468ba0a10d86b660eebed98d1b484cbce113a7/src/layers/basic.jl#L170
If the type need two or more functions, it is common to define a new method with the type on the first argument like Base.parse.
Thank you for your answer
23:29:20
@dionisos:matrix.orgdionisosI admit I doesn’t know the syntax you are using, I will try to understand how it works23:30:01
@dionisos:matrix.orgdionisosI mean the "(v::MyType)"23:30:14
@dionisos:matrix.orgdionisos

ERROR: LoadError: syntax: Global method definition around test.jl:2 needs to be placed at the top level, or use "eval".

23:57:18
@dionisos:matrix.orgdionisos

When I try like that :

function create_function(MyType)
	function (test::MyType)(a::MyType, b::MyType)
		return a+b
	end
	return test
end
23:58:20
29 Dec 2023
@dionisos:matrix.orgdionisos

Ok I found how to do that, it should be :

function create_function(MyType, value)
	function test(a::MyType, b::MyType) where MyType
		return a+b
	end
	return test
end

But I admit I don’t really understand why.

00:04:23
@dionisos:matrix.orgdionisosAlso I am curious about the "(test::MyType)" syntax00:05:41
@qwjyh:matrix.orgqwjyhDo you want to generate a function based on a type automatically? If normal multiple dispatch doesn't meet your need, you should use macro.00:06:12
@dionisos:matrix.orgdionisos *

Ok I found how to do that, it should be :

function create_function(MyType)
	function test(a::MyType, b::MyType) where MyType
		return a+b
	end
	return test
end

But I admit I don’t really understand why.

00:07:15

Show newer messages


Back to Room ListRoom Version: