I think Jameson's solution would be best most of the time.  Otherwise
use a macro

macro barfn()
    esc(quote
        function bar(y)
            return x + y
        end
        end)
end

function foo(value)
    x = value
    @barfn
    println(bar(10))
end


On Mon, 2015-02-09 at 14:35, Chang Kwon <[email protected]> wrote:
> Thanks, Jameson. That means, I have to actually write bar(y) within the 
> function foo(value), right?
>
> I have foo(), foo1(), foo2(), foo3(), all of which use the same bar(y). 
> Should I repeatedly write the code for bar(y) for all foo functions? Is 
> there any other way?
>
> I can make the bar() function as bar(x,y), but it is not an option to me 
> for some reasons.

Reply via email to