As a work-around, you can define a function `getx() = (global x; x)`, and
use it to access the global variable x.

-erik

On Sun, Sep 18, 2016 at 5:31 PM, Marius Millea <mariusmil...@gmail.com>
wrote:

> I'd like to access global variables from the default values of keywords
> arguments, e.g.:
>
> x = 3
> function f(;x=x) #<- this default value of x here should refer to x in
> the global scope which is 3
>    ...
> end
>
> Is there any way to do this? I had guessed the following might work but it
> doesn't:
>
> function f(;x=(global x; x))
>    ...
> end
>



-- 
Erik Schnetter <schnet...@gmail.com>
http://www.perimeterinstitute.ca/personal/eschnetter/

Reply via email to