-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Description
For performance reasons, we usually do not need to evaluate the second argument of the something function. For example, in this pattern I sometimes use for propagating default arguments:
function foo(; bar=nothing)
bar = something(bar, defaultbar())
...
end
I propose a lazy version of this, @something:
macro something(valornothing, ex)
return valornothing == :nothing ? ex : valornothing
end
to be used as follows:
function foo(; bar=nothing)
bar = @something(bar, defaultbar())
...
end
so that defaultbar() need not be called when it is not needed.
Metadata
Metadata
Assignees
Labels
No labels