Great, thanks Mauro, most helpful.
On Friday, April 1, 2016 at 4:09:30 PM UTC+11, Mauro wrote: > > Maybe like so: > > julia> module Myfunc > export f > f(x) = g(x) * g(x) > function g end > end > > julia> using Myfunc > > julia> f(4) > ERROR: MethodError: `g` has no method matching g(::Int64) > in f at none:3 > > julia> Myfunc.g(x) = 2x > g (generic function with 1 method) > > julia> f(4) > 64 > > On Fri, 2016-04-01 at 05:39, [email protected] <javascript:> wrote: > > Hi all, > > > > This works: > > f(x) = g(x) * g(x) > > g(x) = x + 1 > > f(2) # 9 > > > > That is, f(x) isn't fully defined until g is defined. > > > > But if f(x) is in a module it doesn't work: > > module myfunc > > export f > > f(x) = g(x) * g(x) > > end > > > > using myfunc > > g(x) = x + 1 > > f(2) # ERROR: UndefVarError: g not defined > > > > That is, myfunc.f(x) cannot access global g(x) if g(x) is defined after > > myfunc (or even before). Is it possible to enable myfunc.f to "see" g? > > Any other ways to achieve the same thing? > > > > Cheers, > > Jock >
