Closed
Description
As discussed on Discourse, it would be nice to have !foo
return a ComposedFunction
, which would
- allow dispatch and specialized methods for
!foo
- allow nicer pretty printing of
!foo
as"!foo"
rather than as"#xx (generic function with 1 method)"
(by overloadingshow
forComposedFunction{typeof(!)}
) - allow
!!foo === foo
Although !foo
and f ∘ g
were introduced at the same time in #17155, when ∘
was subsequently updated in Julia 1.6 to return a special ComposedFunction
type (#37517), the !
implementation was not correspondingly updated, which seems like an oversight.
On a related note, it would also be good to fix the ComposedFunction
show method to put parentheses around operators (or other composed functions), as this is currently broken:
julia> (!) ∘ isnan
! ∘ isnan
julia> ! ∘ isnan
ERROR: syntax: "∘" is not a unary operator
Stacktrace:
[1] top-level scope
@ none:1
Should be a fairly easy PR.