Thanks! That makes sense. That is actually one of the oldest and most painful gotchas about python; most people don't realize that expressions in function declarations are only evaluated once (making super-nasty bugs if you try to have default arguments that are dicts/lists).
I fixed it for 90% of cases by leaving it a symbol, and just evaling it once to get deftype from the eval. It's not perfect, but it should cover most sane cases. I updated the gist (including new test cases for this example) at: https://gist.github.com/sunetos/0714ae73647160d76aae On Friday, May 9, 2014 12:40:58 PM UTC-4, David Moon wrote: > > Consider this: > > someval="foo" > def f(x::Int, @maybe y::String=someval) = (x,y) > f(1) => (1, "foo") > someval="bar" > f(2) => (2, "foo") # should be (2, "bar") > > def g(x) = x + " seen" > def h(x::String, @maybe y::String=g(x)) = y > h("foo") # gives an error but should be "foo seen" > > See what I am getting at now about when default is evaluated? >