-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guidelines for nested functions #58
Comments
Closures necessarily must at least come after the variables they're capturing. |
Function should not be nested, unless they are closures e.g. # Yes
function _bar(v::String)
return string(v, v)
end
function foo()
var = "Test"
return _bar(var)
end
# No
function foo()
function _bar(v::String)
return string(v, v)
end
var = "Test"
return _bar(var)
end # Yes
function func(x)
y = g(x)
function _bar(v::String)
return string(v, y)
end
return y, _bar
end
# Not valid:
function _bar(v::String)
return string(v, y)
end
function func(x)
y = g(x)
return y, _bar
end |
ChainRules.jl nests functions that are not closures sometimes. Is this a case of exceptions are exceptional? Or a sign of a wider pattern, |
Maybe; that was my first thought.
i could very easily be convinced of this |
Just wanted to open up a chat about if functions should be nested, and if so where should they live?
OR
OR
The text was updated successfully, but these errors were encountered: