Skip to content
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

!foo should use (!) ∘ foo #44748

Closed
stevengj opened this issue Mar 25, 2022 · 1 comment · Fixed by #44752
Closed

!foo should use (!) ∘ foo #44748

stevengj opened this issue Mar 25, 2022 · 1 comment · Fixed by #44752
Labels
good first issue Indicates a good issue for first-time contributors to Julia kind:feature Indicates new feature / enhancement requests

Comments

@stevengj
Copy link
Member

stevengj commented Mar 25, 2022

As discussed on Discourse, it would be nice to have !foo return a ComposedFunction, which would

  1. allow dispatch and specialized methods for !foo
  2. allow nicer pretty printing of !foo as "!foo" rather than as "#xx (generic function with 1 method)" (by overloading show for ComposedFunction{typeof(!)})
  3. 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.

@stevengj stevengj added good first issue Indicates a good issue for first-time contributors to Julia kind:feature Indicates new feature / enhancement requests labels Mar 25, 2022
@markmbaum
Copy link
Contributor

I can try to do this if that's alright. Wanted to contribute for a while and seems like a good opportunity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Indicates a good issue for first-time contributors to Julia kind:feature Indicates new feature / enhancement requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants