Parametric types & multiple dispatch

Lincoln_Hannah
Fri, 24 Nov 2023 01:12:00 +0000
General Usage

Method choice can be determined by a parametric type

struct X{x} end

f(::X{:x1}) = 1
f(::X{:x2}) = 2

f(X{:x1}()) # 1
f(X{:x2}()) # 2

Why not allow it to be determined just with the parameter ?

f({:x1}) = 1
f({:x2}) = 2

f({:x1}) # 1
f({:x1}) # 2

8 posts - 3 participants