Re: [julia-users] constrain arguments in function

2015-09-15 Thread Mauro
Related, in Julia0.4 there is also enum: help?> @enum .. @enum EnumName EnumValue1[=x] EnumValue2[=y] Create an :obj:`Enum` type with name ``EnumName`` and enum member values of ``EnumValue1`` and ``EnumValue2`` with optional assigned values of ``x`` and ``y``, respectively. ``EnumName``

Re: [julia-users] constrain arguments in function

2015-09-15 Thread Mauro
No, Julia only dispatches on types not on values. The latter sometimes goes under the name of pattern matching. There is a package for that: https://github.com/toivoh/PatternDispatch.jl On Tue, 2015-09-15 at 10:15, Michael Borregaard wrote: > Is there a way in julia to

Re: [julia-users] constrain arguments in function

2015-09-15 Thread Sisyphuss
Shouldn't it be function foo(x, method::SolverMethod) ... end foo(x, Kendall) # solve using Kendall solver ? if isa(method, Spearman) # do spearman specific stuff elseif isa(method, Pearson) # do pearson specific stuff elseif isa(method, Kendall) # do kendall specific stuff else # handle

[julia-users] constrain arguments in function

2015-09-15 Thread Michael Borregaard
Is there a way in julia to restrict the values of arguments to a function, eg to the contents of a certain vector? So, e.g. method in the function function foo(x, method::String) ... would be constrained to either "spearman", "pearson" or "kendall"? Thanks

Re: [julia-users] constrain arguments in function

2015-09-15 Thread Milan Bouchet-Valat
Le mardi 15 septembre 2015 à 03:04 -0700, Michael Borregaard a écrit : > Ahh, I remember enum from the good old C++ days. That looks useful, > but in reality I guess still not more user friendly than just taking > a string defining the method, and then writing in the documentation > that it can

Re: [julia-users] constrain arguments in function

2015-09-15 Thread Michael Krabbe Borregaard
Thanks, I will look into that then. So essentially if I build a module I export the enums used for all functions into the global workspace? On Tue, Sep 15, 2015 at 2:22 PM, Milan Bouchet-Valat wrote: > Le mardi 15 septembre 2015 à 03:04 -0700, Michael Borregaard a écrit : > >