Thanks Mauro, I think that is good enough for what I am trying to do. The return type is already a very good assertion, I wished there was also something similar for the argument types.
thanks! El jueves, 20 de febrero de 2014 12:07:47 UTC+1, Mauro escribió: > > There is no way of declaring the return type of a function. See > https://github.com/JuliaLang/julia/issues/1090 > > But it would be nice if there was. Nor is there a way to dispatch on > the input argument types of functions: say you only want to accept > functions with signature (::Int, ::Float64). > > You can annotate the callback with ::T to assert that it > returns the right type. > > function myFunc( someArg::Int64, callbackFn::Function ) > # do something > # then call callbackFn > callbackFn( <args> )::Int64 > end > > > On Thu, 2014-02-20 at 10:49, [email protected] <javascript:> wrote: > > Hello, > > > > I am trying to find out how to specify the type of a callback function, > for > > example suppose > > > > function myFunc( someArg::Int64, callbackFn ) > > # do something > > # then call callbackFn > > callbackFn( <args> ) > > end > > > > I would like to specify the type of callbackFn, for example returning > Int64 > > and taking a tuple as arguments. > > I looked at the docs but maybe I missed it, but which is the syntax for > > specifying a function type? > > > > Thanks. > >
